home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / novia / src / novia_nsl.c < prev    next >
Text File  |  1999-12-06  |  65KB  |  2,471 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <stdlib.h>
  4. #include <pragma/exec_lib.h>
  5. #include <pragma/dos_lib.h>
  6. #include <dos/dos.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9. #include <ctype.h>
  10. #include <time.h>
  11. #include <novia/novia_nsl.h>
  12. #include <pragma/noviasys_lib.h>
  13. #include <novia/novia_portdata.h>
  14. #include <novia/novia_userdata.h>
  15.  
  16. #ifndef NOVIA_REGISTERS_H
  17. #include <novia/novia_registers.h>
  18. #endif
  19.  
  20. //#define SCREENWIDTH cport->LocalUser.TermWidth
  21. #define SCREENWIDTH 80
  22.  
  23. extern char editfield(char *bp, char *src, char maxlen, char fieldlen, ULONG flags, ULONG sigs);
  24. extern MainPortConfig *mainportconfig;
  25.  
  26. BPTR mulder;                    // filehandle
  27. char buffer[256];
  28. char *ptr;
  29. char programend = FALSE;    // global exit
  30. ULONG linecounter    = 0;
  31.  
  32. List variablelist;
  33. List structurelist;;
  34.  
  35. __saveds ASM LONG nslib_execute_nsl(register __a0 char *name);
  36.  
  37. int LoadStructureKeys(struct StructureList *sl, char *filename);
  38. void initglobal();
  39. void freeglobal();
  40.  
  41. LONG getcommandid(char *string);
  42. int nslcmd_print(char *string);
  43. struct NSLVariable *getvariable(char *name);
  44. struct NSLVariable *addvariable(char *name);
  45. StructureEntry *searchuserkey(StructureList *sl, char *name);
  46. int myisalpha(char c);
  47. struct NSLMenu *CreateMenu(NSLVariable *var);
  48.  
  49. struct NSLMenuItem *CreateMenuEntry_PRINT();
  50. struct NSLMenuItem *CreateMenuEntry_NULL();
  51. struct NSLMenuItem *CreateMenuEntry_FIELD();
  52. struct NSLMenuItem *CreateMenuEntry_TEXT();
  53. struct NSLMenuItem *CreateMenuEntry_LINK();
  54. struct NSLMenuItem *CreateMenuEntry_RETURN();
  55.  
  56. BOOL islink(ULONG nsltype);
  57. void jump_menu(NSLMenu *);
  58. void update_item_data(NSLMenuItem *item);
  59. void build_menu(NSLMenu *nslmenu);
  60.  
  61. LONG returncode = NULL;
  62.  
  63. int GetNextGraph()
  64. {
  65.     int result = FALSE;
  66.     char quit = FALSE;
  67.     while (!quit && !programend)
  68.     {
  69.         if (!*ptr | *ptr == 10 | *ptr == 13)        // next line;
  70.         {
  71.             if (FGets(mulder, buffer, 256))
  72.             {
  73.                 linecounter++;
  74.                 ptr = buffer;
  75.                 while ( *ptr && !isgraph(*ptr) && *ptr != 10 && *ptr != 13)
  76.                     ptr++;
  77.                 if (isgraph(*ptr))
  78.                     quit = TRUE;
  79.             }
  80.             else
  81.                 programend = TRUE;
  82.         }
  83.         else
  84.         {
  85.             while (isgraph(*ptr) && *ptr && *ptr != 10 && *ptr != 13)
  86.                 ptr++;
  87.  
  88.             if (isgraph(*ptr))
  89.             {
  90.                 if (*ptr == ';')
  91.                 {
  92.                     *ptr = 0;            // comment. jump to next line;
  93.                 }
  94.                 else
  95.                 {
  96.                     quit = TRUE;
  97.                 }
  98.             }
  99.             else
  100.             {
  101.                 while (!isgraph(*ptr) && *ptr && *ptr != 10 && *ptr != 13)
  102.                     ptr++;
  103.                 if (isgraph(*ptr))
  104.                 {
  105.                     quit = TRUE;
  106.                 }
  107.                 else
  108.                 {
  109.                     *ptr = 0;
  110.                 }
  111.             }
  112.         }
  113.     }
  114.     if (!programend)
  115.         result = TRUE;
  116.     return result;
  117. }
  118.  
  119.  
  120. __saveds ASM LONG nslib_execute_nsl(register __a0 char *name)
  121. {
  122.     struct PortData *cport = (PortData *)FindTask(NULL)->tc_UserData;
  123.     char acmd[256];                // actualcommand
  124.     char *acmdptr;                    // pointer for line tracing
  125.     struct NSLVariable *avar;    // actualvariable
  126.     char quit;
  127.     ULONG counter;
  128.  
  129.     programend = FALSE;    // global exit
  130.     linecounter    = 0;
  131.  
  132.     ioprintf("inin\n");
  133.     initglobal();
  134.     if ((mulder = Open(name, MODE_OLDFILE)))
  135.     {
  136.         NSLVariable *var;
  137.         ptr = buffer;
  138.         *ptr = 0;
  139.  
  140.         while (!programend && !cport->ProgramClose && cport->network.online)
  141.         {
  142.             while (GetNextGraph())
  143.             {
  144.                 quit    = FALSE;
  145.                 *acmd = 0;
  146.                 if (myisalpha(*ptr))                            // check for keyword
  147.                 {
  148.                     acmdptr = acmd;
  149.                     while (myisalpha(*ptr))
  150.                         *acmdptr++ = *ptr++;
  151.                     *acmdptr = 0;
  152.                     switch(getcommandid(acmd))
  153.                     {
  154.                         case NSL_TYPE_COMMENT:
  155.                             while (*ptr && *ptr != 10 && *ptr != 13)
  156.                                 ptr++;
  157.                             break;
  158.                         case NSLCOMMAND_PRINT:
  159.                             ptr = ptr + nslcmd_print(ptr);
  160.                             break;
  161.                         case NSLCOMMAND_EXIT:
  162.                             programend = TRUE;
  163.                             break;
  164.                         case NSLCOMMAND_MENU:
  165.                             break;
  166.                         case NSLCOMMAND_JUMP:
  167.                             acmdptr = acmd;
  168.                             while (*ptr && !myisalpha(*ptr))
  169.                                 ptr++;
  170.                             while (myisalpha(*ptr))
  171.                                 *acmdptr++ = *ptr++;
  172.                             *acmdptr = 0;
  173.                             if ((var = getvariable(acmd)))
  174.                             {
  175.                                 if (var->nsltype == NSL_TYPE_MENU && var->data)
  176.                                     jump_menu((NSLMenu *)var->data);
  177.                             }
  178.                             break;
  179.                         case NSLCOMMAND_IF:
  180.                             acmdptr = acmd;
  181.                             while (*ptr && !myisalpha(*ptr)) // jump to variable
  182.                                 ptr++;
  183.  
  184.                             while (myisalpha(*ptr))
  185.                                 *acmdptr++ = *ptr++;
  186.                             *acmdptr = 0;
  187.  
  188.                             if ((var = getvariable(acmd)))
  189.                             {
  190.                                 ioprintf("ptr2:%s\n",ptr);
  191.                                 while (isspace(*ptr))
  192.                                     ptr++;
  193.                                 ioprintf("ptr2:%s\n",ptr);
  194.                                 if (*ptr == '=' && isspace(ptr[1]))
  195.                                 {
  196.                                     ptr++;
  197.                                     while (*ptr && !isgraph(*ptr))
  198.                                         ptr++;
  199.                                     acmdptr = acmd;
  200.                                     while (isgraph(*ptr))
  201.                                         *acmdptr++ = *ptr++;
  202.                                     *acmdptr = 0;
  203.                                     if (getcommandid(acmd) == NSL_RESULT_TRUE)
  204.                                     {
  205.                                         if (var->nsltype == NSL_TYPE_MENU)
  206.                                         {
  207.                                             if (var->result)
  208.                                             {
  209.                                                 while (isgraph(*ptr))
  210.                                                     ptr++;
  211.                                                 while (isspace(*ptr))
  212.                                                     ptr++;
  213.                                                 acmdptr = acmd;
  214.                                                 while (isgraph(*ptr))
  215.                                                     *acmdptr++ = *ptr++;
  216.                                                 *acmdptr = 0;
  217.                                                 if (getcommandid(acmd) == NSLCOMMAND_THEN)
  218.                                                 {
  219.                                                     while (isgraph(*ptr))
  220.                                                         ptr++;
  221.                                                     while (isspace(*ptr))
  222.                                                         ptr++;
  223.                                                     acmdptr = acmd;
  224.                                                     while (*ptr && *ptr != '(')
  225.                                                         *acmdptr++ = *ptr++;
  226.                                                     *acmdptr = 0;
  227.                                                     if (getcommandid(acmd) == NSLCOMMAND_SAVECOMMANDENTRY)
  228.                                                     {
  229.                                                         while (isgraph(*ptr) && *ptr != '(')
  230.                                                             ptr++;
  231.                                                         if (*ptr == '(')
  232.                                                         {
  233.                                                             ptr++;
  234.                                                             acmdptr = acmd;
  235.                                                             while (*ptr && *ptr != ')')
  236.                                                                 *acmdptr++ = *ptr++;
  237.                                                             *acmdptr = 0;
  238.                                                             if ((var = getvariable(acmd)))
  239.                                                             {
  240.                                                                 if (var->nsltype == NSL_TYPE_STRUCT)
  241.                                                                 {
  242.                                                                     if (!(ndos_save_ndos_object(cport->argstring[1], (APTR)var->data)))
  243.                                                                     {
  244.                                                                     }
  245.                                                                     else
  246.                                                                     {
  247.                                                                         programend = TRUE;
  248.                                                                         ioprintf("programerror 23 in line: %d <%s>.\n",linecounter,ptr);
  249.                                                                     }
  250.                                                                 }
  251.                                                                 else
  252.                                                                 {
  253.                                                                     programend = TRUE;
  254.                                                                     ioprintf("programerror 23.1 in line: %d <%s>.\n",linecounter,ptr);
  255.                                                                 }
  256.                                                             }
  257.                                                             else
  258.                                                             {
  259.                                                                 programend = TRUE;
  260.                                                                 ioprintf("programerror 23.2 in line: %d <%s>.\n",linecounter,ptr);
  261.                                                             }
  262.                                                         }
  263.                                                         else
  264.                                                         {
  265.                                                             programend = TRUE;
  266.                                                             ioprintf("programerror 23.3 in line: %d <%s>.\n",linecounter,ptr);
  267.                                                         }
  268.                                                     }
  269.                                                     else if (getcommandid(acmd) == NSLCOMMAND_SAVEUSER)
  270.                                                     {
  271.                                                         while (isgraph(*ptr) && *ptr != '(')
  272.                                                             ptr++;
  273.                                                         if (*ptr == '(')
  274.                                                         {
  275.                                                             ptr++;
  276.                                                             acmdptr = acmd;
  277.                                                             while (*ptr && *ptr != ')')
  278.                                                                 *acmdptr++ = *ptr++;
  279.                                                             *acmdptr = 0;
  280.                                                             if ((var = getvariable(acmd)))
  281.                                                             {
  282.                                                                 if (var->nsltype == NSL_TYPE_STRUCT)
  283.                                                                 {
  284.                                                                     SaveUser(&cport->EditUser);
  285.                                                                 }
  286.                                                                 else
  287.                                                                 {
  288.                                                                     programend = TRUE;
  289.                                                                     ioprintf("programerror 23.1 in line: %d <%s>.\n",linecounter,ptr);
  290.                                                                 }
  291.                                                             }
  292.                                                             else
  293.                                                             {
  294.                                                                 programend = TRUE;
  295.                                                                 ioprintf("programerror 23.2 in line: %d <%s>.\n",linecounter,ptr);
  296.                                                             }
  297.                                                         }
  298.                                                         else
  299.                                                         {
  300.                                                             programend = TRUE;
  301.                                                             ioprintf("programerror 23.3 in line: %d <%s>.\n",linecounter,ptr);
  302.                                                         }
  303.                                                     }
  304.                                                     else
  305.                                                     {
  306.                                                         programend = TRUE;
  307.                                                         ioprintf("programerror 23.4 in line: %d <%s>.\n",linecounter,ptr);
  308.                                                     }
  309.                                                 }
  310.                                                 else
  311.                                                 {
  312.                                                     programend = TRUE;
  313.                                                     ioprintf("programerror 23.5 in line: %d <%s>.\n",linecounter,ptr);
  314.                                                 }
  315.                                             }
  316.                                             else
  317.                                                 {
  318.                                                 programend = TRUE;
  319.                                                 ioprintf("programerror 23.6 in line: %d <%s>.\n",linecounter,ptr);
  320.                                             }
  321.                                         }
  322.                                         else
  323.                                         {
  324.                                             programend = TRUE;
  325.                                             ioprintf("programerror 23.7 in line: %d <%s>.\n",linecounter,ptr);
  326.                                         }
  327.                                     }
  328.                                     else
  329.                                     {
  330.                                         programend = TRUE;
  331.                                         ioprintf("programerror 23.8 in line: %d <%s>.\n",linecounter,ptr);
  332.                                     }
  333.                                 }
  334.                                 else
  335.                                 {
  336.                                     programend = TRUE;
  337.                                     ioprintf("programerror 23.9 in line: %d <%s>.\n",linecounter,ptr);
  338.                                 }
  339.                             }
  340.                             else
  341.                                 programend = TRUE;
  342.                             break;
  343.                         case NSLCOMMAND_UNDEFINED:
  344.                             {
  345.                                 struct NSLVariable *var;
  346.                                 var = getvariable(acmd);
  347.                                 while (*ptr && *ptr != 10 && *ptr != 13 && *ptr != ':' && *ptr !='=')
  348.                                     *ptr++;
  349.                                 if (*ptr == ':')                            // Label
  350.                                 {
  351.                                     if (var)
  352.                                     {
  353.                                         ioprintf("ERROR 100, in line: %d -> Label %s already defined.\n",linecounter,acmd);
  354.                                     }
  355.                                     else
  356.                                     {
  357.                                         if ((var = addvariable(acmd)))
  358.                                         {
  359.                                             ioprintf("addviarable: %s\n",acmd);
  360.                                             var->nsltype    = NSL_TYPE_LABEL;
  361.                                             var->data        = linecounter;
  362.                                         }
  363.                                     }
  364.                                 }
  365.                                 else
  366.                                 {
  367.                                     if (isgraph(*ptr))
  368.                                     {
  369.                                         if (*ptr == '=')
  370.                                         {
  371.                                             while (isgraph(*ptr))
  372.                                                 ptr++;
  373.                                             if (!var)
  374.                                                 var = addvariable(acmd);
  375.                                             if (var)
  376.                                             {
  377.                                                 while (*ptr && *ptr != 10 && *ptr != 13 && !isgraph(*ptr))
  378.                                                     ptr++;
  379.                                                 if (*ptr && *ptr != 10 && *ptr != 13)
  380.                                                 {
  381.                                                     if (myisalpha(*ptr))
  382.                                                     {
  383.                                                         StructureList *sl;
  384.                                                         NSLMenu *nslmenu;
  385.                                                         acmdptr = acmd;
  386.                                                         while (myisalpha(*ptr))
  387.                                                             *acmdptr++ = *ptr++;
  388.                                                         *acmdptr = 0;
  389.                                                         switch (getcommandid(acmd))
  390.                                                         {
  391.                                                             case NSLCOMMAND_MENU:
  392.                                                                 ioprintf("Create Menu: %d\n",linecounter);
  393.                                                                 var->nsltype = NSL_TYPE_MENU;
  394.                                                                 if (nslmenu = CreateMenu(var))
  395.                                                                 {
  396.                                                                     nslmenu->title = var->name;
  397.                                                                 }
  398.                                                                 break;
  399.                                                             case NSLCOMMAND_LOADUSER:
  400.                                                                 var->nsltype = NSL_TYPE_STRUCT;
  401.                                                                 sl = (StructureList *)&structurelist.lh_Head;
  402.                                                                 while (sl && sl->ln_Succ)
  403.                                                                 {
  404.                                                                     if (sl->sl_id == NSL_SLID_USER)
  405.                                                                         var->sl = sl;
  406.                                                                     sl = sl->ln_Succ;
  407.                                                                 }
  408.                                                                 while (*ptr && (*ptr == '(' | isspace(*ptr)))
  409.                                                                     ptr++;
  410.                                                                 if (myisalpha(*ptr))
  411.                                                                 {
  412.                                                                     acmdptr = acmd;
  413.                                                                     while (*ptr && myisalpha(*ptr))
  414.                                                                         *acmdptr++ = *ptr++;
  415.                                                                     *acmdptr = 0;
  416.                                                                     if (getcommandid(acmd) == NSL_TYPE_ARGSTRING)
  417.                                                                     {
  418.                                                                         ULONG userid = NULL;
  419.                                                                         if ((userid = FindUser(cport->argstring[1])))
  420.                                                                         {
  421.                                                                             if (LoadUser(&cport->EditUser,userid))
  422.                                                                             {
  423.                                                                                 var->data = (ULONG) &cport->EditUser;
  424.                                                                             }
  425.                                                                             else
  426.                                                                             {
  427.                                                                                 programend = TRUE;
  428.                                                                                 ioprintf("programerror 33 in line: %d, can't load user\n",linecounter);
  429.                                                                             }
  430.                                                                         }
  431.                                                                         else
  432.                                                                         {
  433.                                                                             programend = TRUE;
  434.                                                                             ioprintf("programerror 34 in line: %d, can't get userid\n",linecounter);
  435.                                                                         }
  436.                                                                     }
  437.                                                                     else
  438.                                                                     {
  439.                                                                         programend = TRUE;
  440.                                                                         ioprintf("programerror 35 in line: %d, empty argument string\n",linecounter);
  441.                                                                     }
  442.                                                                 }
  443.                                                                 break;
  444.                                                             case NSLCOMMAND_LOADMAINCONFIG:
  445.                                                                 var->nsltype = NSL_TYPE_STRUCT;
  446.                                                                 sl = (StructureList *)&structurelist.lh_Head;
  447.                                                                 while (sl && sl->ln_Succ)
  448.                                                                 {
  449.                                                                     if (sl->sl_id == NSL_SLID_MAINCONFIG)
  450.                                                                         var->sl = sl;
  451.                                                                     sl = sl->ln_Succ;
  452.                                                                 }
  453.                                                                 while (*ptr && (*ptr == ')' | isspace(*ptr)))
  454.                                                                     ptr++;
  455.                                                                 var->data = (ULONG) mainportconfig;
  456.                                                                 break;
  457.  
  458.                                                             case NSLCOMMAND_LOADCOMMANDENTRY:
  459.  
  460.                                                                 var->nsltype = NSL_TYPE_STRUCT;
  461.                                                                 sl = (StructureList *)&structurelist.lh_Head;
  462.                                                                 while (sl && sl->ln_Succ)
  463.                                                                 {
  464.                                                                     if (sl->sl_id == NSL_SLID_COMMANDENTRY)
  465.                                                                         var->sl = sl;
  466.                                                                     sl = sl->ln_Succ;
  467.                                                                 }
  468.                                                                 while (*ptr && (*ptr == '(' | isspace(*ptr)))
  469.                                                                     ptr++;
  470.                                                                 if (myisalpha(*ptr))
  471.                                                                 {
  472.                                                                     acmdptr = acmd;
  473.                                                                     while (*ptr && myisalpha(*ptr))
  474.                                                                         *acmdptr++ = *ptr++;
  475.                                                                     *acmdptr = 0;
  476.                                                                     if (getcommandid(acmd) == NSL_TYPE_ARGSTRING)
  477.                                                                     {
  478.                                                                         struct CommandEntry *ce;
  479.                                                                         if ((ce = AllocVec(sizeof(CommandEntry), MEMF_ANY | MEMF_CLEAR)))
  480.                                                                         {
  481.                                                                             LONG doserror;
  482.                                                                             if (!(doserror = ndos_load_ndos_object(cport->argstring[1], ce)))
  483.                                                                             {
  484.                                                                                 printf("command entry->structure: %x\n",ce);
  485.                                                                                 var->data = (ULONG)ce;
  486.                                                                             }
  487.                                                                             else
  488.                                                                             {
  489.                                                                                 programend = TRUE;
  490.                                                                                 ioprintf("programerror 23 in line: %d, %s.\n",linecounter,getstr(150,(UWORD)doserror));
  491.                                                                             }
  492.                                                                         }
  493.                                                                         else
  494.                                                                         {
  495.                                                                             programend = TRUE;
  496.                                                                             ioprintf("programerror 24 in line: %d, out of memory\n",linecounter);
  497.                                                                         }
  498.                                                                     }
  499.                                                                     else
  500.                                                                     {
  501.                                                                         programend = TRUE;
  502.                                                                         ioprintf("programerror 25 in line: %d, empty argument string\n",linecounter);
  503.                                                                     }
  504.                                                                 }
  505.                                                                 break;
  506.                                                         }
  507.                                                     }
  508.                                                 }
  509.                                             }
  510.                                         }
  511.                                         else
  512.                                         {
  513.                                             ioprintf("ptr: <%s>\n",ptr);
  514.                                         }
  515.                                     }
  516.                                     else
  517.                                     {
  518.                                         ioprintf("programerror 26 in line: %d, <%s>\n",linecounter,ptr);
  519.                                         programend = TRUE;
  520.                                     }
  521.                                 }
  522.                             }
  523.                             break;
  524.                     }
  525.                 }
  526.                 else
  527.                     ioprintf("warning dfgfd in line: %d\n",linecounter);
  528.             }
  529.             linecounter++;
  530.         }
  531.         Close(mulder);
  532.     }
  533.     else
  534.     {
  535.         returncode = ERROR_OBJECT_NOT_FOUND;
  536.         ioprintf("can't open nsl-program: %s\n",name);
  537.     }
  538.     freeglobal();
  539.     ioprintf("c3z0\n");
  540.     return(returncode);
  541. }
  542.  
  543. LONG getcommandid(char *string)
  544. {
  545.     if (!strcmp(string,"FALSE"))                                    return NSL_RESULT_FALSE;
  546.     if (!strcmp(string,"TRUE"))                                    return NSL_RESULT_TRUE;
  547.  
  548.     if (*string == ';')                                                return NSL_TYPE_COMMENT;
  549.  
  550.     if (!strcmp(string,"PRINT"))                                    return NSLCOMMAND_PRINT;
  551.     if (!strcmp(string,"EXIT"))                                    return NSLCOMMAND_EXIT;
  552.     if (!strcmp(string,"MENU"))                                    return NSLCOMMAND_MENU;
  553.     if (!strcmp(string,"JUMP"))                                    return NSLCOMMAND_JUMP;
  554.     if (!strcmp(string,"PROCEDURE"))                                return NSLCOMMAND_PROCEDURE;
  555.     if (!strcmp(string,"IF"))                                        return NSLCOMMAND_IF;
  556.     if (!strcmp(string,"THEN"))                                    return NSLCOMMAND_THEN;
  557.     if (!strcmp(string,"ELSE"))                                    return NSLCOMMAND_ELSE;
  558.     if (!strcmp(string,"LOADUSER"))                                return NSLCOMMAND_LOADUSER;
  559.     if (!strcmp(string,"SAVEUSER"))                                return NSLCOMMAND_SAVEUSER;
  560.     if (!strcmp(string,"LOADMAINCONFIG"))                        return NSLCOMMAND_LOADMAINCONFIG;
  561.     if (!strcmp(string,"LOADCOMMANDENTRY"))                    return NSLCOMMAND_LOADCOMMANDENTRY;
  562.     if (!strcmp(string,"SAVECOMMANDENTRY"))                    return NSLCOMMAND_SAVECOMMANDENTRY;
  563.     if (!strcmp(string,"MENUTAG_COLS"))                            return NSL_MENUTAG_COLS;
  564.     if (!strcmp(string,"MENUTAG_AUTOFORMAT"))                    return NSL_MENUTAG_AUTOFORMAT;
  565.     if (!strcmp(string,"FIELD"))                                    return NSL_TYPE_FIELD;
  566.     if (!strcmp(string,"TEXT"))                                    return NSL_TYPE_TEXT;
  567.     if (!strcmp(string,"LINK"))                                    return NSL_TYPE_LINK;
  568.     if (!strcmp(string,"RETURN"))                                    return NSL_TYPE_RETURN;
  569.     if (!strcmp(string,"NULL"))                                    return NSL_TYPE_NULL;
  570.     if (!strcmp(string,"ARGSTRING"))                                return NSL_TYPE_ARGSTRING;
  571.  
  572.     if (!strcmp(string,"NSL_TYPE_ACCESSGROUP"))                return NSL_TYPE_ACCESSGROUP;
  573.     if (!strcmp(string,"NSL_TYPE_ANSICOLORS"))                return NSL_TYPE_ANSICOLORS;
  574.     if (!strcmp(string,"NSL_TYPE_ANSIMODE"))                    return NSL_TYPE_ANSIMODE;
  575.     if (!strcmp(string,"NSL_TYPE_ANSITABS"))                    return NSL_TYPE_ANSITABS;
  576.     if (!strcmp(string,"NSL_TYPE_ARCMETHOD"))                    return NSL_TYPE_ARCMETHOD;
  577.     if (!strcmp(string,"NSL_TYPE_BOOL"))                        return NSL_TYPE_BOOL;
  578.     if (!strcmp(string,"NSL_TYPE_CHARSET"))                    return NSL_TYPE_CHARSET;
  579.     if (!strcmp(string,"NSL_TYPE_COMPUTERTYPE"))                return NSL_TYPE_COMPUTERTYPE;
  580.     if (!strcmp(string,"NSL_TYPE_COUNTRY"))                    return NSL_TYPE_COUNTRY;
  581.     if (!strcmp(string,"NSL_TYPE_DATE"))                        return NSL_TYPE_DATE;
  582.     if (!strcmp(string,"NSL_TYPE_DIRECTORYPATH"))            return NSL_TYPE_DIRECTORYPATH;
  583.     if (!strcmp(string,"NSL_TYPE_EOLSEQUENCE"))                return NSL_TYPE_EOLSEQUENCE;
  584.     if (!strcmp(string,"NSL_TYPE_GENDER"))                        return NSL_TYPE_GENDER;
  585.     if (!strcmp(string,"NSL_TYPE_HELPLEVEL"))                    return NSL_TYPE_HELPLEVEL;
  586.     if (!strcmp(string,"NSL_TYPE_LANGUAGE"))                    return NSL_TYPE_LANGUAGE;
  587.     if (!strcmp(string,"NSL_TYPE_LINEFEEDS"))                    return NSL_TYPE_LINEFEEDS;
  588.     if (!strcmp(string,"NSL_TYPE_MOREMODE"))                    return NSL_TYPE_MOREMODE;
  589.     if (!strcmp(string,"NSL_TYPE_PHONENUMBER"))                return NSL_TYPE_PHONENUMBER;
  590.     if (!strcmp(string,"NSL_TYPE_PHONEVERIFICATION"))        return NSL_TYPE_PHONEVERIFICATION;
  591.     if (!strcmp(string,"NSL_TYPE_PROTOCOL"))                    return NSL_TYPE_PROTOCOL;
  592.     if (!strcmp(string,"NSL_TYPE_STRING"))                        return NSL_TYPE_STRING;
  593.     if (!strcmp(string,"NSL_TYPE_TIMEFORMAT"))                return NSL_TYPE_TIMEFORMAT;
  594.     if (!strcmp(string,"NSL_TYPE_TIMEZONE"))                    return NSL_TYPE_TIMEZONE;
  595.     if (!strcmp(string,"NSL_TYPE_UBYTE"))                        return NSL_TYPE_UBYTE;
  596.     if (!strcmp(string,"NSL_TYPE_ULONG"))                        return NSL_TYPE_ULONG;
  597.     if (!strcmp(string,"NSL_TYPE_USERID"))                        return NSL_TYPE_USERID;
  598.     if (!strcmp(string,"NSL_TYPE_UWORD"))                        return NSL_TYPE_UWORD;
  599.     if (!strcmp(string,"NSL_TYPE_GROUPBOOL"))                    return NSL_TYPE_GROUPBOOL;
  600.     if (!strcmp(string,"NSL_TYPE_DATEFORMAT"))                return NSL_TYPE_DATEFORMAT;
  601.     if (!strcmp(string,"NSL_TYPE_STRUCT"))                        return NSL_TYPE_STRUCT;
  602.     if (!strcmp(string,"NSL_TYPE_FILENAME"))                    return NSL_TYPE_FILENAME;
  603.     if (!strcmp(string,"NSL_TYPE_DOMAIN"))                        return NSL_TYPE_DOMAIN;
  604.     if (!strcmp(string,"NSL_TYPE_INETADDRESS"))                return NSL_TYPE_INETADDRESS;
  605.     if (!strcmp(string,"NSL_TYPE_INETSERVICEPORT"))            return NSL_TYPE_INETSERVICEPORT;
  606.     if (!strcmp(string,"NSL_TYPE_INETUSERLIST"))                return NSL_TYPE_INETUSERLIST;
  607.     if (!strcmp(string,"NSL_TYPE_INETSERVERSTATUS"))        return NSL_TYPE_INETSERVERSTATUS;
  608.     if (!strcmp(string,"NSL_TYPE_INETMAILUSERTYPE"))        return NSL_TYPE_INETMAILUSERTYPE;
  609.     if    (!strcmp(string,"NSL_TYPE_INETUSERNAME"))                return NSL_TYPE_INETUSERNAME;
  610.     if    (!strcmp(string,"NSL_TYPE_IPADDRESS"))                    return NSL_TYPE_IPADDRESS;
  611.     if    (!strcmp(string,"NSL_TYPE_SCREENMODE"))                return NSL_TYPE_SCREENMODE;
  612.     if    (!strcmp(string,"NSL_TYPE_FONTNAME"))                    return NSL_TYPE_FONTNAME;
  613.     if    (!strcmp(string,"NSL_TYPE_CLIENTLIST"))                return NSL_TYPE_CLIENTLIST;
  614.     if    (!strcmp(string,"NSL_TYPE_LOCALMAILSERVERLIST"))    return NSL_TYPE_LOCALMAILSERVERLIST;
  615.     if    (!strcmp(string,"NSL_TYPE_POP3SERVERLIST"))            return NSL_TYPE_POP3SERVERLIST;
  616.     if    (!strcmp(string,"NSL_TYPE_EVENTLIST"))                    return NSL_TYPE_EVENTLIST;
  617.     if (!strcmp(string,"NSL_TYPE_USERIP"))                        return NSL_TYPE_USERIP;
  618.     if (!strcmp(string,"NSL_TYPE_ITEMTYPE"))                    return NSL_TYPE_ITEMTYPE;
  619.     if (!strcmp(string,"NSL_TYPE_PROTECTION"))                return NSL_TYPE_PROTECTION;
  620.  
  621. //    if (!strcmp(string,""))                        return
  622.     return NSLCOMMAND_UNDEFINED;
  623. }
  624.  
  625.  
  626. int nslcmd_print(char *string)
  627. {
  628.     char *ptr = string;
  629.     char quit = FALSE;
  630.     char iobuffer[256];
  631.     char *ioptr = iobuffer;
  632.     while (!quit)
  633.     {
  634.         if (*ptr == '"')                                                            // detected "string"
  635.         {
  636.             *ptr++;
  637.             while (*ptr && *ptr != 10 && *ptr != 13 && *ptr != '"')    // wait for second " or lineend
  638.                 *ioptr++ = *ptr++;                                                // copy string in iobuffer
  639.  
  640.             if (*ptr == '"')                                                        // check of second "
  641.                 *ptr++;
  642.             *ioptr++ = ' ';
  643.         }
  644.         else
  645.         {
  646.             if (isdigit(*ptr))                                                    // check for integer
  647.             {
  648.                 while (isdigit(*ptr) | *ptr == '.' | *ptr == 44)        // ascii for , is 44
  649.                 {
  650.                     if (*ptr == ',')
  651.                     {
  652.                         *ioptr++ = '.';                                            // convert , in .
  653.                         *ptr++;
  654.                     }
  655.                     else
  656.                         *ioptr++ = *ptr++;
  657.                 }
  658.                 *ioptr++ = ' ';
  659.             }
  660.             else
  661.             {
  662.                 if (!*ptr | *ptr == 10 | *ptr == 13 | *ptr == ';')        // check end of line or next command
  663.                     quit = TRUE;
  664.                 else
  665.                 {
  666.                     if (myisalpha(*ptr))
  667.                     {
  668.                         char varname[100];
  669.                         char *varnameptr = varname;
  670.                         struct NSLVariable *var;
  671.                         while (myisalpha(*ptr))
  672.                             *varnameptr++ = *ptr++;
  673.                         *varnameptr = 0;
  674.                         var = getvariable(varname);
  675.                         if (var)
  676.                         {
  677.                             switch (var->nsltype)
  678.                             {
  679.                                 case NSL_TYPE_ULONG: case NSL_TYPE_UWORD: case NSL_TYPE_UBYTE:
  680.                                     sprintf(ioptr,"%u",var->data);
  681.                                     ioptr = ioptr + strlen(ioptr);
  682.                                     break;
  683.                                 case NSL_TYPE_NOTDEFINED:
  684.                                     strcat(ioptr,"<>");
  685.                                     ioptr++;
  686.                                     break;
  687.                                 case NSL_TYPE_STRING:
  688.                                     strcpy(ioptr,(char *)var->data);
  689.                                     ioptr = ioptr + strlen(ioptr);
  690.                                     break;
  691.                             }
  692.                         }
  693.                     }
  694.                     else
  695.                     {
  696.                         *ptr++;
  697.                     }
  698.                 }
  699.             }
  700.         }
  701.     }
  702.     *ioptr = 0;
  703.     ioprintf("stdout: %s\n",iobuffer);
  704.     return(ptr - string);
  705. }
  706.  
  707.  
  708. struct NSLVariable *getvariable(char *name)
  709. {
  710.     struct NSLVariable *result = NULL;
  711.     struct NSLVariable *var;
  712.  
  713.     var = (NSLVariable *)variablelist.lh_Head;        // get first variable
  714.  
  715.     while (var->ln_Succ && !result)
  716.     {
  717.         if (!strcmp(var->name, name))
  718.         {
  719.             result = var;
  720.         }
  721.         else
  722.             var = var->ln_Succ;
  723.     }
  724.     if (result)
  725.     {
  726.         if (!strcmp(name, "TIME"))
  727.         {
  728.             char *ctimeout;
  729.             time_t t = time(0);
  730.             ctimeout = ctime(&t);
  731.             if ((result->data = (ULONG) AllocVec(strlen(ctimeout), MEMF_ANY|MEMF_CLEAR))) // allocate memory for var->data
  732.             {
  733.                 /* copy global-timestring into var->data. ctime hangs a CR on the global timestring.
  734.                     Is this normaly ?? Or a nice bug of my MaxonC++ Compiler ?? */
  735.  
  736.                 strncpy((APTR)result->data, ctimeout, strlen(ctimeout) - 1);
  737.             }
  738.         }
  739.     }
  740.  
  741.     return result;
  742. }
  743.  
  744. struct NSLVariable *addvariable(char *name)
  745. {
  746.     struct NSLVariable *var = NULL;
  747.     if ((var = AllocVec(sizeof(struct NSLVariable), MEMF_ANY | MEMF_CLEAR)))
  748.     {
  749.         if ((var->name = AllocVec(strlen(name) + 1, MEMF_ANY | MEMF_CLEAR)))
  750.         {
  751.             strcpy(var->name, name);
  752.             AddTail(&variablelist, (Node *)var);
  753.         }
  754.         else
  755.         {
  756.             FreeVec(var);
  757.             var = NULL;
  758.         }
  759.     }
  760.     return var;
  761. }
  762.  
  763. int myisalpha(char c)
  764. {
  765.     if (isalpha(c) |  c == '_')
  766.         return TRUE;
  767.     else
  768.         return FALSE;
  769. }
  770.  
  771.  
  772. int LoadStructureKeys(struct StructureList *sl, char *filename)
  773. {
  774.     int result = NULL;
  775.     BPTR fh;
  776.     NewList((List *)&sl->se_list);
  777.     if ((fh = Open(filename, MODE_OLDFILE)))
  778.     {
  779.         char line[256];
  780.         char *lineptr;
  781.         char *septr;
  782.         struct StructureEntry *se;
  783.         while (FGets(fh, line, 256) && !programend)
  784.         {
  785.             if ((se = AllocVec(sizeof(StructureEntry), MEMF_ANY | MEMF_CLEAR)))
  786.             {
  787.                 lineptr    = line;
  788.                 septr        = se->se_name;
  789.                 
  790.                 while (!isgraph(*lineptr))
  791.                     lineptr++;
  792.  
  793.                 /* get se_name */
  794.  
  795.                 while (*lineptr && isgraph(*lineptr))
  796.                     *septr++ = *lineptr++;
  797.  
  798.                 /* jump to offset */
  799.  
  800.                 while (*lineptr && !isdigit(*lineptr))
  801.                     lineptr++;
  802.  
  803.                 /* test for offset */
  804.  
  805.                 if (isdigit(*lineptr))
  806.                 {
  807.  
  808.                     /* get offset */
  809.  
  810.                     lineptr = lineptr + StrToLong(lineptr, (LONG *)&se->se_offset);
  811.  
  812.                     /* als naechstes offseteintrag (isdigit) überspringen und zur fieldlen springen.
  813.                         wegen eines Bugs in StrToLong liefert StringToLong vor AmigaOS V39 nicht die Anzahl
  814.                         der konvertierten zahlen zurück, sondern die tabulatoren. */
  815.  
  816.                     while (isdigit(*lineptr))                    // jump to end of offset-digit-string.
  817.                         lineptr++;
  818.  
  819.                     while (*lineptr && !isdigit(*lineptr))    // jump to first digit of fieldlen
  820.                         lineptr++;
  821.  
  822.                     if (isdigit(*lineptr))                        // teste ob das naechste Zeichen eine Zahl ist.
  823.                     {
  824.                         lineptr = lineptr + StrToLong(lineptr, (LONG *)&se->se_length);    // get fieldlen
  825.  
  826.                         /* springe zum ersten buchstaben des ItemTypes */
  827.  
  828.                         while (*lineptr && !isalpha(*lineptr))
  829.                             lineptr++;
  830.  
  831.                         if (myisalpha(*lineptr))                // teste auf alphabetischen Zeichen.
  832.                         {
  833.  
  834.                             /* kopiere itemtype bis zum ende der zeile */
  835.  
  836.                             char *lineptr2 = lineptr;
  837.                             while (*lineptr2)
  838.                             {
  839.                                 if (*lineptr2 == 10 | *lineptr2 == 13)
  840.                                     *lineptr2 = 0;
  841.                                 lineptr2++;
  842.                             }
  843.                             se->se_type = getcommandid(lineptr);    // get ItemType
  844.                             AddTail((List *)&sl->se_list, (Node *)se);
  845.                             result++;
  846.                         }
  847.                         else
  848.                         {
  849.                             programend = TRUE;
  850.                             ioprintf("add us failat 3:<%s> <%s>\n",lineptr,sl->sl_name);
  851.                         }
  852.                     }
  853.                     else
  854.                     {
  855.                         programend = TRUE;
  856.                         ioprintf("add us failat 2:<%s> <%s>\n",lineptr,sl->sl_name);
  857.                     }
  858.                 }
  859.                 else
  860.                 {
  861.                     programend = TRUE;
  862.                     ioprintf("add us failat 1:<%s> <%s>\n",lineptr,sl->sl_name);
  863.                 }
  864.             }
  865.             else
  866.             {
  867.                 programend = TRUE;
  868.                 ioprintf("add us failat 0:<%s> <%s>\n",lineptr,sl->sl_name);
  869.             }
  870.         }
  871.         Close(fh);
  872.     }
  873.     else
  874.     {
  875.         ioprintf("(failed)\ncan't open userkeys\n");
  876.         programend = TRUE;
  877.     }
  878.     return result;
  879. }
  880.  
  881. void initglobal()
  882. {
  883.     struct NSLVariable *var;
  884.     struct StructureList *sl;
  885.  
  886.     NewList(&structurelist);
  887.     NewList(&variablelist);
  888.  
  889.     if ((var = addvariable("TIME")))
  890.     {
  891.         var->nsltype = NSL_TYPE_STRING;
  892.     }
  893.  
  894.     if ((sl = AllocVec(sizeof(StructureList), MEMF_ANY|MEMF_CLEAR)))
  895.     {
  896.         strcpy(sl->sl_name,"USER");
  897.         sl->sl_id = NSL_SLID_USER;
  898.         if (LoadStructureKeys(sl, "novia:sysdata/nsl/structures/user"))
  899.         {
  900.             AddTail((List *)&structurelist, (Node *)sl);
  901.         }
  902.         else
  903.         {
  904.             FreeVec(sl);
  905.             programend = TRUE;
  906.             ioprintf("can't open novia:sysdata/nsl/structures/user");
  907.         }
  908.     }
  909.  
  910.     if ((sl = AllocVec(sizeof(StructureList), MEMF_ANY|MEMF_CLEAR)))
  911.     {
  912.         strcpy(sl->sl_name,"MAINCONFIG");
  913.         sl->sl_id = NSL_SLID_MAINCONFIG;
  914.         if (LoadStructureKeys(sl, "novia:sysdata/nsl/structures/mainconfig"))
  915.         {
  916.             AddTail((List *)&structurelist, (Node *)sl);
  917.         }
  918.         else
  919.         {
  920.             FreeVec(sl);
  921.             programend = TRUE;
  922.             ioprintf("can't open novia:sysdata/nsl/structures/mainconfig");
  923.         }
  924.     }
  925.  
  926.     if ((sl = AllocVec(sizeof(StructureList), MEMF_ANY|MEMF_CLEAR)))
  927.     {
  928.         strcpy(sl->sl_name,"INETCONFIG");
  929.         sl->sl_id = NSL_SLID_INETCONFIG;
  930.         if (LoadStructureKeys(sl, "novia:sysdata/nsl/structures/inetconfig"))
  931.         {
  932.             AddTail((List *)&structurelist, (Node *)sl);
  933.         }
  934.         else
  935.         {
  936.             FreeVec(sl);
  937.             programend = TRUE;
  938.             ioprintf("can't open novia:sysdata/nsl/structures/inetconfig");
  939.         }
  940.     }
  941.  
  942.     if ((sl = AllocVec(sizeof(StructureList), MEMF_ANY|MEMF_CLEAR)))
  943.     {
  944.         strcpy(sl->sl_name,"LOCALMAILSERVER");
  945.         sl->sl_id = NSL_SLID_LOCALMAILSERVER;
  946.         if (LoadStructureKeys(sl, "novia:sysdata/nsl/structures/localmailserver"))
  947.         {
  948.             AddTail((List *)&structurelist, (Node *)sl);
  949.         }
  950.         else
  951.         {
  952.             FreeVec(sl);
  953.             programend = TRUE;
  954.             ioprintf("can't open novia:sysdata/nsl/structures/localmailserver");
  955.         }
  956.     }
  957.  
  958.     if ((sl = AllocVec(sizeof(StructureList), MEMF_ANY|MEMF_CLEAR)))
  959.     {
  960.         strcpy(sl->sl_name,"POP3SERVER");
  961.         sl->sl_id = NSL_SLID_POP3SERVER;
  962.         if (LoadStructureKeys(sl, "novia:sysdata/nsl/structures/pop3server"))
  963.         {
  964.             AddTail((List *)&structurelist, (Node *)sl);
  965.         }
  966.         else
  967.         {
  968.             FreeVec(sl);
  969.             programend = TRUE;
  970.             ioprintf("can't open novia:sysdata/nsl/structures/pop3server");
  971.         }
  972.     }
  973.  
  974.     if ((sl = AllocVec(sizeof(StructureList), MEMF_ANY|MEMF_CLEAR)))
  975.     {
  976.         strcpy(sl->sl_name,"INETMAILUSER");
  977.         sl->sl_id = NSL_SLID_INETMAILUSER;
  978.         if (LoadStructureKeys(sl, "novia:sysdata/nsl/structures/inetmailuser"))
  979.         {
  980.             AddTail((List *)&structurelist, (Node *)sl);
  981.         }
  982.         else
  983.         {
  984.             FreeVec(sl);
  985.             programend = TRUE;
  986.             ioprintf("can't open novia:sysdata/nsl/structures/inetmailuser");
  987.         }
  988.     }
  989.  
  990.     if ((sl = AllocVec(sizeof(StructureList), MEMF_ANY|MEMF_CLEAR)))
  991.     {
  992.         strcpy(sl->sl_name,"COMMANDENTRY");
  993.         sl->sl_id = NSL_SLID_COMMANDENTRY;
  994.         if (LoadStructureKeys(sl, "novia:sysdata/nsl/structures/commandentry"))
  995.         {
  996.             AddTail((List *)&structurelist, (Node *)sl);
  997.         }
  998.         else
  999.         {
  1000.             FreeVec(sl);
  1001.             programend = TRUE;
  1002.             ioprintf("can't open novia:sysdata/nsl/structures/commandentry");
  1003.         }
  1004.     }
  1005. }
  1006.  
  1007. void freeglobal()
  1008. {
  1009.     struct NSLVariable *var;
  1010.     struct StructureEntry *se;
  1011.     struct StructureList  *sl;
  1012.     while (!IsListEmpty(&variablelist))
  1013.     {
  1014.         var = (NSLVariable *)variablelist.lh_Head;
  1015.         if (var->ln_Succ)
  1016.         {
  1017.             if (var->name)
  1018.                 FreeVec(var->name);
  1019.             Remove((Node *)var);
  1020.             FreeVec(var);
  1021.         }
  1022.         var = var->ln_Succ;
  1023.     }
  1024.  
  1025.     while (!IsListEmpty(&structurelist))
  1026.     {
  1027.         sl = (StructureList *)structurelist.lh_Head;
  1028.         Remove((Node *)sl);
  1029.         while (!IsListEmpty((List *)&sl->se_list))
  1030.         {
  1031.             se = (StructureEntry *)sl->se_list.mlh_Head;
  1032.             Remove((Node *)se);
  1033.             FreeVec(se);
  1034.         }
  1035.         FreeVec(sl);
  1036.     }
  1037. }
  1038.  
  1039. struct NSLMenu *CreateMenu(NSLVariable *var)
  1040. {
  1041.     struct PortData *cport    = (struct PortData *)FindTask(NULL)->tc_UserData;
  1042.     char acmd[256];                // actualcommand
  1043.     char *acmdptr;                    // pointer for line tracing
  1044.     char varname[100];
  1045.     char *varnameptr = varname;
  1046.     char spalte = 1;
  1047.     char line    = 1;
  1048.     struct NSLMenu  *nslmenu;
  1049.     char quit = FALSE;
  1050.  
  1051.     if ((nslmenu = AllocVec(sizeof(struct NSLMenu), MEMF_ANY | MEMF_CLEAR)))
  1052.     {
  1053.         NewList((List *)&nslmenu->itemlist);
  1054.         var->data        = (ULONG) nslmenu;
  1055.         nslmenu->var    = var;
  1056.         while (!isgraph(*ptr) && *ptr && *ptr != 10 && *ptr != 13)
  1057.             ptr++;
  1058.         while (!quit && !programend)
  1059.         {
  1060.             if (*ptr == '(')
  1061.             {
  1062.                 ptr++;
  1063.                 quit = TRUE;
  1064.             }
  1065.             else
  1066.                 GetNextGraph();
  1067.         }
  1068.  
  1069.         if (!programend)
  1070.             quit = FALSE;
  1071.         while (!quit && !programend)
  1072.         {
  1073.             if (!isgraph(*ptr))
  1074.             {
  1075.                 if (!GetNextGraph())
  1076.                 {
  1077.                     quit = TRUE;
  1078.                     programend = TRUE;
  1079.                     ioprintf("unexcpected program error in line: %d\n",linecounter);
  1080.                 }
  1081.                 else
  1082.                 {
  1083.                     ioprintf("getnextgraph error\n");
  1084.                     quit = TRUE;
  1085.                     programend = TRUE;
  1086.                 }
  1087.  
  1088.             }
  1089.             if (isgraph(*ptr))
  1090.             {
  1091.                 acmdptr = acmd;
  1092.                 while (myisalpha(*ptr))
  1093.                     *acmdptr++ = *ptr++;
  1094.                 *acmdptr = 0;
  1095.                 switch (getcommandid(acmd))
  1096.                 {
  1097.                     case NSL_MENUTAG_COLS:
  1098.                         if (!nslmenu->colums)
  1099.                         {
  1100.                             char int_found = FALSE;
  1101.                             while (!int_found)
  1102.                             {
  1103.                                 while (*ptr && *ptr != 10 && *ptr != 13 && !isdigit(*ptr))
  1104.                                     *ptr++;
  1105.                                 if (isdigit(*ptr))
  1106.                                 {
  1107.                                     nslmenu->colums = atoi(ptr);
  1108.                                     if (nslmenu->colums == 0 | nslmenu->colums> 10)
  1109.                                     {
  1110.                                         quit            = TRUE;
  1111.                                         programend    = TRUE;
  1112.                                         ioprintf("create MENU-Error: unvalid colums %d\n",nslmenu->colums);
  1113.                                     }
  1114.                                     int_found    = TRUE;
  1115.                                 }
  1116.                                 else
  1117.                                 {
  1118.                                     if (!GetNextGraph())
  1119.                                     {
  1120.                                         int_found    = TRUE;
  1121.                                         quit            = TRUE;
  1122.                                     }
  1123.                                 }
  1124.                             }
  1125.                         }
  1126.                         else
  1127.                         {
  1128.                             ioprintf("menu colums already defined");
  1129.                             programend = TRUE;
  1130.                         }
  1131.                         break;
  1132.                     case NSL_MENUTAG_AUTOFORMAT:
  1133. //                        ioprintf("MENU AUTOFORMAT\n");
  1134.                         break;
  1135.                     case NSLCOMMAND_PRINT:
  1136.                         {
  1137.                             struct NSLMenuItem *item = CreateMenuEntry_PRINT();
  1138.                             if (item)
  1139.                             {
  1140.                                 item->X = spalte;
  1141.                                 item->Y = line;
  1142.                                 if (spalte == nslmenu->colums)
  1143.                                 {
  1144.                                     spalte = 1;
  1145.                                     line++;
  1146.                                 }
  1147.                                 else
  1148.                                 {
  1149.                                     spalte++;
  1150.                                 }
  1151.                                 AddTail((List *)&nslmenu->itemlist, (Node *)item);
  1152.                                 item->nsltype = NSL_TYPE_TEXT;
  1153.                                 nslmenu->entrys++;
  1154.                             }
  1155.                         }
  1156.                         break;
  1157.                     case NSL_TYPE_NULL:
  1158.                         {
  1159.                             if (spalte == nslmenu->colums)
  1160.                             {
  1161.                                 spalte = 1;
  1162.                                 line++;
  1163.                             }
  1164.                             else
  1165.                             {
  1166.                                 spalte++;
  1167.                             }
  1168.                         }
  1169.                         break;
  1170.                     case NSL_TYPE_FIELD:
  1171.                         {
  1172.                             struct NSLMenuItem *item = CreateMenuEntry_PRINT();
  1173.                             if (item)
  1174.                             {
  1175.                                 item->X = spalte;
  1176.                                 item->Y = line;
  1177.                                 if (spalte == nslmenu->colums)
  1178.                                 {
  1179.                                     spalte = 1;
  1180.                                     line++;
  1181.                                 }
  1182.                                 else
  1183.                                 {
  1184.                                     spalte++;
  1185.                                 }
  1186.                                 AddTail((List *)&nslmenu->itemlist, (Node *)item);
  1187.                                 item->nsltype = NSL_TYPE_FIELD;
  1188.                                 nslmenu->entrys++;
  1189.                             }
  1190.                         }
  1191.                         break;
  1192.                     case NSL_TYPE_TEXT:
  1193.                         {
  1194.                             struct NSLMenuItem *item = CreateMenuEntry_TEXT();
  1195.                             if (item)
  1196.                             {
  1197.                                 item->X = spalte;
  1198.                                 item->Y = line;
  1199.                                 if (spalte == nslmenu->colums)
  1200.                                 {
  1201.                                     spalte = 1;
  1202.                                     line++;
  1203.                                 }
  1204.                                 else
  1205.                                 {
  1206.                                     spalte++;
  1207.                                 }
  1208.                                 AddTail((List *)&nslmenu->itemlist, (Node *)item);
  1209.                                 nslmenu->entrys++;
  1210.                             }
  1211.                         }
  1212.                         break;
  1213.                     case NSL_TYPE_LINK:
  1214.                         {
  1215.                             struct NSLMenuItem *item = CreateMenuEntry_LINK();
  1216.                             if (item)
  1217.                             {
  1218.                                 item->X = spalte;
  1219.                                 item->Y = line;
  1220.                                 if (spalte == nslmenu->colums)
  1221.                                 {
  1222.                                     spalte = 1;
  1223.                                     line++;
  1224.                                 }
  1225.                                 else
  1226.                                 {
  1227.                                     spalte++;
  1228.                                 }
  1229.                                 AddTail((List *)&nslmenu->itemlist, (Node *)item);
  1230.                                 item->nsltype = NSL_TYPE_LINK;
  1231.                                 nslmenu->entrys++;
  1232.                             }
  1233.                         }
  1234.                         break;
  1235.                     case NSL_TYPE_RETURN:
  1236.                         {
  1237.                             struct NSLMenuItem *item = CreateMenuEntry_RETURN();
  1238.                             if (item)
  1239.                             {
  1240.                                 ioprintf("create return\n");
  1241.                                 item->nsltype = NSL_TYPE_RETURN;
  1242.                                 item->X = spalte;
  1243.                                 item->Y = line;
  1244.                                 if (spalte == nslmenu->colums)
  1245.                                 {
  1246.                                     spalte = 1;
  1247.                                     line++;
  1248.                                 }
  1249.                                 else
  1250.                                 {
  1251.                                     spalte++;
  1252.                                 }
  1253.                                 AddTail((List *)&nslmenu->itemlist, (Node *)item);
  1254.                                 nslmenu->entrys++;
  1255.                             }
  1256.                         }
  1257.                         break;
  1258.                     case NSLCOMMAND_UNDEFINED:
  1259.                         if (*ptr == ')')
  1260.                         {
  1261.                             ptr++;
  1262.                             quit = TRUE;
  1263.                         }
  1264.                         break;
  1265.                 }
  1266.                 if (!quit)
  1267.                 {
  1268.                     if (!GetNextGraph())
  1269.                     {
  1270.                         ioprintf("program errrorrr in line: %d\n",linecounter);
  1271.                         programend = TRUE;
  1272.                         quit = TRUE;
  1273.                     }
  1274.                 }
  1275.             }
  1276.             else
  1277.             {
  1278.                 ioprintf("error ???\n");
  1279.             }
  1280.         }
  1281.         if (nslmenu->colums <= 0 | nslmenu->colums >= 10)
  1282.             programend = TRUE;
  1283.         if (!programend)
  1284.         {
  1285.             char collen[10];
  1286.             char xpos[10];
  1287.             char length;
  1288.             char counter;
  1289.             char multiplicator = SCREENWIDTH / nslmenu->colums;
  1290.             char space = 0;
  1291.             char *newtitle;
  1292.             char *newptr;
  1293.             char *oldptr;
  1294.             NSLMenuItem *item = (NSLMenuItem *)nslmenu->itemlist.mlh_Head;
  1295.             for (counter = 9; (counter--);)
  1296.                 collen[counter] = 0;
  1297.             while (item->ln_Succ)
  1298.             {
  1299.                 length = strlen(item->title);
  1300.                 if (length > collen[item->X])
  1301.                     collen[item->X] = length;
  1302.                 item = item->ln_Succ;
  1303.             }
  1304.             for (counter = 1; counter <= nslmenu->colums; counter++)
  1305.             {
  1306.                 space = space + collen[counter] + 1;
  1307.             }
  1308.             space = (SCREENWIDTH - space + 1) / nslmenu->colums;
  1309.             xpos[1] = 1;
  1310.             for (counter = 2; counter <= nslmenu->colums; counter++)
  1311.             {
  1312.                 xpos[counter] = xpos[counter - 1] + collen[counter - 1] + space + 1;
  1313.             }
  1314.             item = (NSLMenuItem *)nslmenu->itemlist.mlh_Head;
  1315.             while (item->ln_Succ)
  1316.             {
  1317.                 item->titlelen = collen[item->X] + 1;
  1318.                 if (item->title)
  1319.                 {
  1320.                     if ((newtitle = AllocVec(100, MEMF_ANY|MEMF_CLEAR)))
  1321.                     {
  1322.                         newptr = newtitle;
  1323.                         oldptr = item->title;
  1324.                         while (*oldptr)
  1325.                             *newptr++ = *oldptr++;
  1326.                         for (counter = strlen(item->title); counter < collen[item->X]; counter++)
  1327.                             *newptr++ = ' ';
  1328.                         if (item->nsltype == NSL_TYPE_LINK)
  1329.                             *newptr++ = '>';
  1330.                         else if (item->nsltype != NSL_TYPE_RETURN)
  1331.                             *newptr++ = ':';
  1332.                         FreeVec(item->title);
  1333.                         item->title = newtitle;
  1334.                     }
  1335.                 }
  1336.                 item->X = xpos[item->X];
  1337.                 if (item->ln_Succ->ln_Succ)
  1338.                 {
  1339.                     if (item->ln_Succ->Y == item->Y)
  1340.                     {
  1341.                         item->fieldlen = space;
  1342.                     }
  1343.                     else
  1344.                     {
  1345.                         item->fieldlen = SCREENWIDTH - item->X - item->titlelen + 1;
  1346.                     }
  1347.                 }
  1348.                 else
  1349.                     item->fieldlen = SCREENWIDTH - item->X - item->titlelen + 1;
  1350.                 item = item->ln_Succ;
  1351.             }            
  1352.         }
  1353.     }
  1354.     return nslmenu;
  1355. }
  1356.  
  1357.  
  1358.  
  1359. struct NSLMenuItem *CreateMenuEntry_PRINT()
  1360. {
  1361.     struct NSLMenuItem *result = AllocVec(sizeof(NSLMenuItem), MEMF_ANY|MEMF_CLEAR);
  1362.     ULONG counter = 0;
  1363.     char  *ptr2;
  1364.     if (result)
  1365.     {
  1366.         if (!isgraph(*ptr))
  1367.             GetNextGraph();
  1368.         if (*ptr == '(')        // Open found
  1369.         {
  1370.             ptr++;
  1371.             if (!isgraph(*ptr))
  1372.                 GetNextGraph();
  1373.             if (*ptr == '"')    // first " found
  1374.             {
  1375.                 ptr++;
  1376.                 ptr2 = ptr;
  1377.                 while (*ptr2 && *ptr2 != '"')        // search second "
  1378.                 {
  1379.                     counter++;
  1380.                     ptr2++;
  1381.                 }
  1382.                 if (*ptr2 == '"')
  1383.                 {
  1384.                     if ((result->title = AllocVec(counter + 2, MEMF_ANY | MEMF_CLEAR)))
  1385.                     {
  1386.                         ptr2 = result->title;
  1387.                         while (*ptr && *ptr != '"')        // copy title 'nd wait for second "
  1388.                             *ptr2++ = *ptr++;
  1389.                         if (*ptr)
  1390.                         {
  1391.                             ptr++;                                    // jump to next character after "
  1392.                             while(*ptr && !myisalpha(*ptr))    // space over
  1393.                                 ptr++;
  1394.                             if (myisalpha(*ptr))
  1395.                             {
  1396.                                 char name[100];
  1397.                                 char *nameptr = name;
  1398.                                 while (*ptr && myisalpha(*ptr))    // komma weg
  1399.                                     *nameptr++ = *ptr++;
  1400.                                 *nameptr = 0;
  1401.                                 if (!(result->var = getvariable(name)))
  1402.                                 {
  1403.                                     if ((result->var = addvariable(name)))
  1404.                                     {
  1405.                                         result->var->nsltype = NSL_TYPE_STRUCT;
  1406.                                     }
  1407.                                 }
  1408.                                 if (result->var)
  1409.                                 {
  1410.                                     while (*ptr && !isgraph(*ptr))
  1411.                                         ptr++;
  1412.                                     if (isgraph(*ptr))
  1413.                                     {
  1414.                                         if (*ptr == '-' && ptr[1] == '>')
  1415.                                         {
  1416.                                             ptr = ptr + 2;
  1417.                                             while (*ptr && !isgraph(*ptr))
  1418.                                                 ptr++;
  1419.                                             if (result->var->nsltype == NSL_TYPE_NOTDEFINED)
  1420.                                                 result->var->nsltype = NSL_TYPE_STRUCT;
  1421.                                             if (result->var->nsltype == NSL_TYPE_STRUCT)
  1422.                                             {
  1423.                                                 StructureEntry *se;
  1424.                                                 nameptr = name;
  1425.                                                 while (*ptr && myisalpha(*ptr))
  1426.                                                     *nameptr++ = *ptr++;
  1427.                                                 *nameptr = 0;
  1428.                                                 if (result->var->sl)
  1429.                                                 {
  1430.                                                     if ((se = searchuserkey(result->var->sl,name)))
  1431.                                                     {
  1432.                                                         result->se_offset    = se->se_offset;
  1433.                                                         result->se_length    = se->se_length;
  1434.                                                         result->se_type    = se->se_type;
  1435.                                                     }
  1436.                                                     else
  1437.                                                     {
  1438.                                                     }
  1439.                                                 }
  1440.                                                 else
  1441.                                                     ioprintf("can't find structure\n");
  1442.                                             }
  1443.                                             else
  1444.                                             {
  1445.                                                 FreeVec(result->title);
  1446.                                                 FreeVec(result);
  1447.                                                 result        = NULL;
  1448.                                                 programend    = TRUE;
  1449.                                                 ioprintf("error in line. %d. variable type of %s alread def.\n",linecounter,result->var->name);
  1450.                                             }
  1451.                                         }
  1452.                                         else
  1453.                                         {
  1454.                                             ioprintf("warning 3 <%s>\n",ptr);
  1455.                                         }
  1456.                                     }
  1457.                                     else
  1458.                                         ioprintf("warning 2\n");
  1459.                                 }
  1460.                                 while (*ptr && *ptr != ')')
  1461.                                     ptr++;
  1462.                             }
  1463.                             else
  1464.                             {
  1465.                                 FreeVec(result->title);
  1466.                                 FreeVec(result);
  1467.                                 result        = NULL;
  1468.                                 programend    = TRUE;
  1469.                                 ioprintf("nsl program error.-456.5\n");
  1470.                             }
  1471.                             
  1472.                         }
  1473.                         else
  1474.                         {
  1475.                             FreeVec(result->title);
  1476.                             FreeVec(result);
  1477.                             result        = NULL;
  1478.                             programend    = TRUE;
  1479.                             ioprintf("nsl program error.-456.4\n");
  1480.                         }                        
  1481.                     }
  1482.                     else
  1483.                     {
  1484.                         FreeVec(result);
  1485.                         result        = NULL;
  1486.                         programend    = TRUE;
  1487.                         ioprintf("nsl program error.-456.2\n");
  1488.                     }
  1489.                 }
  1490.                 else
  1491.                 {
  1492.                     FreeVec(result);
  1493.                     result        = NULL;
  1494.                     programend    = TRUE;
  1495.                     ioprintf("nsl program error.-456.1\n");
  1496.                 }
  1497.             }
  1498.         }
  1499.     }
  1500.     return result;
  1501. }
  1502.  
  1503. StructureEntry *searchuserkey(StructureList *sl, char *name)
  1504. {
  1505.     StructureEntry *result    = NULL;
  1506.     StructureEntry *se;
  1507.  
  1508.     se = (StructureEntry *)sl->se_list.mlh_Head;        // get first variable
  1509.  
  1510.     while (se->ln_Succ && !result)
  1511.     {
  1512.         if (!strcmp(se->se_name, name))
  1513.         {
  1514.             result = se;
  1515.         }
  1516.         else
  1517.             se = se->ln_Succ;
  1518.     }
  1519.  
  1520.     return result;
  1521. }
  1522.  
  1523.  
  1524. struct NSLMenuItem *CreateMenuEntry_TEXT()
  1525. {
  1526.     struct NSLMenuItem *result = AllocVec(sizeof(NSLMenuItem), MEMF_ANY|MEMF_CLEAR);
  1527.     ULONG counter = 0;
  1528.     char  *ptr2;
  1529.     if (result)
  1530.     {
  1531.         if (!isgraph(*ptr))
  1532.             GetNextGraph();
  1533.         if (*ptr == '(')        // Open found
  1534.         {
  1535.             ptr++;
  1536.             if (!isgraph(*ptr))
  1537.                 GetNextGraph();
  1538.             if (*ptr == '"')    // first " found
  1539.             {
  1540.                 ptr++;
  1541.                 ptr2 = ptr;
  1542.                 while (*ptr2 && *ptr2 != '"')        // search second "
  1543.                 {
  1544.                     counter++;
  1545.                     ptr2++;
  1546.                 }
  1547.                 if (*ptr2 == '"')
  1548.                 {
  1549.                     if ((result->title = AllocVec(counter + 2, MEMF_ANY | MEMF_CLEAR)))
  1550.                     {
  1551.                         ptr2 = result->title;
  1552.                         while (*ptr && *ptr != '"')
  1553.                             *ptr2++ = *ptr++;
  1554.                         while (*ptr && *ptr != ')')
  1555.                             ptr++;
  1556.                         if (!*ptr)
  1557.                         {
  1558.                             FreeVec(result);
  1559.                             result        = NULL;
  1560.                             programend    = TRUE;
  1561.                             ioprintf("nsl program error.-456.3\n");
  1562.                         }
  1563.                     }
  1564.                     else
  1565.                     {
  1566.                         FreeVec(result);
  1567.                         result        = NULL;
  1568.                         programend    = TRUE;
  1569.                         ioprintf("nsl program error.-456.2\n");
  1570.                     }
  1571.                 }
  1572.                 else
  1573.                 {
  1574.                     FreeVec(result);
  1575.                     result        = NULL;
  1576.                     programend    = TRUE;
  1577.                     ioprintf("nsl program error.-456.1\n");
  1578.                 }
  1579.             }
  1580.         }
  1581.     }
  1582.     return result;
  1583. }
  1584.  
  1585. struct NSLMenuItem *CreateMenuEntry_FIELD()
  1586. {
  1587.     struct NSLMenuItem *result = AllocVec(sizeof(NSLMenuItem), MEMF_ANY|MEMF_CLEAR);
  1588.     if (result)
  1589.     {
  1590.     }
  1591.     return result;
  1592. }
  1593.  
  1594. struct NSLMenuItem *CreateMenuEntry_LINK()
  1595. {
  1596.     struct NSLMenuItem *result = AllocVec(sizeof(NSLMenuItem), MEMF_ANY|MEMF_CLEAR);
  1597.     ULONG counter = 0;
  1598.     char  *ptr2;
  1599.     if (result)
  1600.     {
  1601.         if (!isgraph(*ptr))
  1602.             GetNextGraph();
  1603.         if (*ptr == '(')        // Open found
  1604.         {
  1605.             ptr++;
  1606.             if (!isgraph(*ptr))
  1607.                 GetNextGraph();
  1608.             if (*ptr == '"')    // first " found
  1609.             {
  1610.                 ptr++;
  1611.                 ptr2 = ptr;
  1612.                 while (*ptr2 && *ptr2 != '"')        // search second "
  1613.                 {
  1614.                     counter++;
  1615.                     ptr2++;
  1616.                 }
  1617.                 if (*ptr2 == '"')
  1618.                 {
  1619.                     if ((result->title = AllocVec(counter + 2, MEMF_ANY | MEMF_CLEAR)))
  1620.                     {
  1621.                         ptr2 = result->title;
  1622.                         while (*ptr && *ptr != '"')
  1623.                             *ptr2++ = *ptr++;
  1624.                         if (*ptr)
  1625.                         {
  1626.                             ptr++;
  1627.                             if (*ptr)
  1628.                             {
  1629.                                 ptr++;
  1630.                                 while(*ptr && !myisalpha(*ptr))
  1631.                                     ptr++;
  1632.                                 if (myisalpha(*ptr))
  1633.                                 {
  1634.                                     char name[100];
  1635.                                     char *nameptr = name;
  1636.                                     while (*ptr && myisalpha(*ptr))
  1637.                                         *nameptr++ = *ptr++;
  1638.                                     *nameptr = 0;
  1639.                                     if (!(result->var = getvariable(name)))
  1640.                                     {
  1641.                                         if ((result->var = addvariable(name)))
  1642.                                         {
  1643.                                             result->var->nsltype = NSL_TYPE_LINK;
  1644.                                         }
  1645.                                     }
  1646.                                     if (result->var)
  1647.                                     {
  1648.                                         while (*ptr && !isgraph(*ptr))
  1649.                                             ptr++;
  1650.                                         if (isgraph(*ptr))
  1651.                                         {
  1652.                                             while (*ptr && !isgraph(*ptr))
  1653.                                                 ptr++;
  1654.                                             if (result->var->nsltype == NSL_TYPE_NOTDEFINED)
  1655.                                                 result->var->nsltype = NSL_TYPE_LINK;
  1656.                                             if (islink(result->var->nsltype))
  1657.                                             {
  1658. //                                                ioprintf("add link: <%s><%s>\n",result->title,result->var->name);
  1659.                                             }
  1660.                                             else
  1661.                                             {
  1662.                                                 FreeVec(result->title);
  1663.                                                 FreeVec(result);
  1664.                                                 result        = NULL;
  1665.                                                 programend    = TRUE;
  1666.                                                 ioprintf("error in line. %d. variable %s has wrong type.\n",linecounter,result->var->name);
  1667.                                             }
  1668.                                         }
  1669.                                         else
  1670.                                             ioprintf("warning 2\n");
  1671.                                     }
  1672.                                     while (*ptr && *ptr != ')')
  1673.                                     ptr++;
  1674.                                 }
  1675.                                 else
  1676.                                 {
  1677.                                     FreeVec(result->title);
  1678.                                     FreeVec(result);
  1679.                                     result        = NULL;
  1680.                                     programend    = TRUE;
  1681.                                     ioprintf("nsl program error.-456.5\n");
  1682.                                 }
  1683.                                 
  1684.                             }
  1685.                             else
  1686.                             {
  1687.                                 FreeVec(result->title);
  1688.                                 FreeVec(result);
  1689.                                 result        = NULL;
  1690.                                 programend    = TRUE;
  1691.                                 ioprintf("nsl program error.-456.4\n");
  1692.                             }                        
  1693.                         }
  1694.                         else
  1695.                         {
  1696.                             FreeVec(result->title);
  1697.                             FreeVec(result);
  1698.                             result        = NULL;
  1699.                             programend    = TRUE;
  1700.                             ioprintf("nsl program error.-456.3\n");
  1701.                         }
  1702.                     }
  1703.                     else
  1704.                     {
  1705.                         FreeVec(result);
  1706.                         result        = NULL;
  1707.                         programend    = TRUE;
  1708.                         ioprintf("nsl program error.-456.2\n");
  1709.                     }
  1710.                 }
  1711.                 else
  1712.                 {
  1713.                     FreeVec(result);
  1714.                     result        = NULL;
  1715.                     programend    = TRUE;
  1716.                     ioprintf("nsl program error.-456.1\n");
  1717.                 }
  1718.             }
  1719.         }
  1720.     }
  1721.     return result;
  1722. }
  1723.  
  1724. struct NSLMenuItem *CreateMenuEntry_RETURN()
  1725. {
  1726.     struct NSLMenuItem *result = AllocVec(sizeof(NSLMenuItem), MEMF_ANY|MEMF_CLEAR);
  1727.     ULONG counter = 0;
  1728.     char  *ptr2;
  1729.     printf("return:\n");
  1730.     if (result)
  1731.     {
  1732.         if (!isgraph(*ptr))
  1733.             GetNextGraph();
  1734.         if (*ptr == '(')        // Open found
  1735.         {
  1736.             ptr++;
  1737.             if (!isgraph(*ptr))
  1738.                 GetNextGraph();
  1739.             if (*ptr == '"')    // first " found
  1740.             {
  1741.                 ptr++;
  1742.                 ptr2 = ptr;
  1743.                 while (*ptr2 && *ptr2 != '"')        // search second "
  1744.                 {
  1745.                     counter++;
  1746.                     ptr2++;
  1747.                 }
  1748.                 if (*ptr2 == '"')
  1749.                 {
  1750.                     if ((result->title = AllocVec(counter + 2, MEMF_ANY | MEMF_CLEAR)))
  1751.                     {
  1752.                         ptr2 = result->title;
  1753.                         while (*ptr && *ptr != '"')
  1754.                             *ptr2++ = *ptr++;
  1755.                         if (*ptr)
  1756.                         {
  1757.                             ptr++;
  1758.                             if (*ptr)
  1759.                             {
  1760.                                 ptr++;
  1761.                                 while(*ptr && !myisalpha(*ptr))
  1762.                                     ptr++;
  1763.                                 if (myisalpha(*ptr))
  1764.                                 {
  1765.                                     char name[100];
  1766.                                     char *nameptr = name;
  1767.                                     while (*ptr && myisalpha(*ptr))
  1768.                                         *nameptr++ = *ptr++;
  1769.                                     *nameptr = 0;
  1770.                                     if (!strcmp(name,"TRUE"))
  1771.                                     {
  1772.                                         result->se_type = NSL_RESULT_TRUE;
  1773.                                     }
  1774.                                     else
  1775.                                     {
  1776.                                         if (!strcmp(name,"FALSE"))
  1777.                                         {
  1778.                                             result->se_type = NSL_RESULT_FALSE;
  1779.                                         }
  1780.                                         else
  1781.                                             programend = TRUE;
  1782.                                     }
  1783.                                     while (*ptr && *ptr != ')')
  1784.                                         ptr++;
  1785.                                 }
  1786.                                 else
  1787.                                 {
  1788.                                     FreeVec(result->title);
  1789.                                     FreeVec(result);
  1790.                                     result        = NULL;
  1791.                                     programend    = TRUE;
  1792.                                     ioprintf("nsl program error.-456.5\n");
  1793.                                 }
  1794.                                 
  1795.                             }
  1796.                             else
  1797.                             {
  1798.                                 FreeVec(result->title);
  1799.                                 FreeVec(result);
  1800.                                 result        = NULL;
  1801.                                 programend    = TRUE;
  1802.                                 ioprintf("nsl program error.-456.4\n");
  1803.                             }                        
  1804.                         }
  1805.                         else
  1806.                         {
  1807.                             FreeVec(result->title);
  1808.                             FreeVec(result);
  1809.                             result        = NULL;
  1810.                             programend    = TRUE;
  1811.                             ioprintf("nsl program error.-456.3\n");
  1812.                         }
  1813.                     }
  1814.                     else
  1815.                     {
  1816.                         FreeVec(result);
  1817.                         result        = NULL;
  1818.                         programend    = TRUE;
  1819.                         ioprintf("nsl program error.-456.2\n");
  1820.                     }
  1821.                 }
  1822.                 else
  1823.                 {
  1824.                     FreeVec(result);
  1825.                     result        = NULL;
  1826.                     programend    = TRUE;
  1827.                     ioprintf("nsl program error.-456.1\n");
  1828.                 }
  1829.             }
  1830.         }
  1831.     }
  1832.     return result;
  1833. }
  1834.  
  1835. struct NSLMenuItem *CreateMenuEntry_NULL()
  1836. {
  1837.     struct NSLMenuItem *result = AllocVec(sizeof(NSLMenuItem), MEMF_ANY|MEMF_CLEAR);
  1838.     return result;
  1839. }
  1840.  
  1841. BOOL islink(ULONG nsltype)
  1842. {
  1843.     BOOL result = FALSE;
  1844.     if (nsltype == NSL_TYPE_LINK | nsltype == NSL_TYPE_MENU | nsltype == NSL_TYPE_LABEL)
  1845.         result = TRUE;
  1846.     return result;
  1847. }
  1848.  
  1849.  
  1850. void jump_menu(NSLMenu *nslmenu)
  1851. {
  1852.     struct PortData *cport    = (struct PortData *)FindTask(NULL)->tc_UserData;
  1853.     char rebuild                = TRUE;
  1854.     char buffer[10];
  1855.     ULONG *longpt;
  1856.     ULONG ulong;
  1857.     UBYTE ubyte;
  1858.     char  quit = FALSE;
  1859.     NSLMenuItem    *item            = (NSLMenuItem *)nslmenu->itemlist.mlh_Head;;
  1860.     char *structure;
  1861.  
  1862.         while (!quit && !programend && !cport->ProgramClose && cport->network.online)
  1863.         {
  1864.             if (rebuild==TRUE)
  1865.             {
  1866.                 build_menu(nslmenu);
  1867.                 if (!item)
  1868.                     item        = (NSLMenuItem *)nslmenu->itemlist.mlh_Head;
  1869.                 rebuild    = FALSE;
  1870.             }
  1871.             if (item)
  1872.             {
  1873.                 if (item->ln_Succ && item->ln_Pred)
  1874.                 {
  1875.                     JumpXY(item->X,item->Y);
  1876.                     ioprintf("%s",item->title);
  1877.                 }
  1878.             }
  1879.             structure = (char *)item->var->data;
  1880.             Conread(buffer,1,0);
  1881.             switch (*buffer)
  1882.             {
  1883.                 case 13:
  1884.                     switch (item->nsltype)
  1885.                     {
  1886.                         case NSL_TYPE_FIELD:
  1887.                             switch (item->se_type)
  1888.                             {
  1889.                                 case NSL_TYPE_ACCESSGROUP:
  1890.                                     {
  1891.                                         char buffer[15];
  1892.                                         char src[15];
  1893.                                         LONG dest;
  1894.                                         if (*(structure + item->se_offset))
  1895.                                             sprintf(src,"%u",*(structure + item->se_offset));
  1896.                                         editfield(buffer,src, 10, item->fieldlen, 0, 0);
  1897.                                         StrToLong(buffer,&dest);
  1898.                                         *(structure + item->se_offset) = (ULONG)dest;
  1899.                                     }
  1900.                                     break;
  1901.                                 case NSL_TYPE_ANSICOLORS:
  1902.                                     switch (*(structure + item->se_offset))
  1903.                                     {
  1904.                                         case 0: case 1: case 16:
  1905.                                             *(structure + item->se_offset) = 2;
  1906.                                             break;
  1907.                                         case 2:
  1908.                                             *(structure + item->se_offset) = 4;
  1909.                                             break;
  1910.                                         case 4:
  1911.                                             *(structure + item->se_offset) = 8;
  1912.                                             break;
  1913.                                         case 8:
  1914.                                             *(structure + item->se_offset) = 16;
  1915.                                             break;
  1916.                                     }
  1917.                                     update_item_data(item);
  1918.                                     break;
  1919.                                 case NSL_TYPE_ANSIMODE:
  1920.                                     if (*(structure + item->se_offset) == TRUE)
  1921.                                         *(structure + item->se_offset) = FALSE;
  1922.                                     else
  1923.                                         *(structure + item->se_offset) = TRUE;
  1924.                                     update_item_data(item);
  1925.                                     break;
  1926.                                 case NSL_TYPE_ANSITABS:
  1927.                                     if (*(structure + item->se_offset) == TRUE)
  1928.                                         *(structure + item->se_offset) = FALSE;
  1929.                                     else
  1930.                                         *(structure + item->se_offset) = TRUE;
  1931.                                     update_item_data(item);
  1932.                                     break;
  1933.                                 case NSL_TYPE_ARCMETHOD:
  1934.                                     if (*(structure + item->se_offset) == TRUE)
  1935.                                         *(structure + item->se_offset) = FALSE;
  1936.                                     else
  1937.                                         *(structure + item->se_offset) = TRUE;
  1938.                                     update_item_data(item);
  1939.                                     break;
  1940.                                 case NSL_TYPE_BOOL:
  1941.                                     if (*(structure + item->se_offset) == TRUE)
  1942.                                         *(structure + item->se_offset) = FALSE;
  1943.                                     else
  1944.                                         *(structure + item->se_offset) = TRUE;
  1945.                                     update_item_data(item);
  1946.                                     break;
  1947.                                 case NSL_TYPE_CHARSET:
  1948.                                     if (*(structure + item->se_offset) < 2)
  1949.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  1950.                                     else
  1951.                                         *(structure + item->se_offset) = 0;
  1952.                                     update_item_data(item);
  1953.                                     break;
  1954.                                 case NSL_TYPE_COMPUTERTYPE:
  1955.                                     if (*(structure + item->se_offset) < 4)
  1956.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  1957.                                     else
  1958.                                         *(structure + item->se_offset) = 0;
  1959.                                     update_item_data(item);
  1960.                                     break;
  1961.                                 case NSL_TYPE_COUNTRY:
  1962.                                     if (*(structure + item->se_offset) < 13)
  1963.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  1964.                                     else
  1965.                                         *(structure + item->se_offset) = 0;
  1966.                                     update_item_data(item);
  1967.                                     break;
  1968.                                 case NSL_TYPE_DATE:
  1969.                                     break;
  1970.                                 case NSL_TYPE_DIRECTORYPATH:
  1971.                                     {
  1972.                                         char buffer[80];
  1973.                                         editfield(buffer,structure + item->se_offset, item->se_length, item->fieldlen, 0, 0);
  1974.                                         strncpy(structure + item->se_offset,buffer,item->se_length - 1);
  1975.                                         update_item_data(item);
  1976.                                     }
  1977.                                     break;
  1978.                                 case NSL_TYPE_EOLSEQUENCE:
  1979.                                     break;
  1980.                                 case NSL_TYPE_FILENAME:
  1981.                                     {
  1982.                                         char buffer[80];
  1983.                                         editfield(buffer,structure + item->se_offset, item->se_length, item->fieldlen, 0, 0);
  1984.                                         strncpy(structure + item->se_offset,buffer,item->se_length - 1);
  1985.                                         update_item_data(item);
  1986.                                     }
  1987.                                     break;
  1988.                                 case NSL_TYPE_GENDER:
  1989.                                     if (*(structure + item->se_offset) == 1)
  1990.                                         *(structure + item->se_offset) = 0;
  1991.                                     else
  1992.                                         *(structure + item->se_offset) = 1;
  1993.                                     update_item_data(item);
  1994.                                     break;
  1995.                                 case NSL_TYPE_HELPLEVEL:
  1996.                                     if (*(structure + item->se_offset) < 2)
  1997.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  1998.                                     else
  1999.                                         *(structure + item->se_offset) = 0;
  2000.                                     update_item_data(item);
  2001.                                     break;
  2002.                                 case NSL_TYPE_ITEMTYPE:
  2003.                                     if (*(structure + item->se_offset) < 10)
  2004.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2005.                                     else
  2006.                                         *(structure + item->se_offset) = 0;
  2007.                                     update_item_data(item);
  2008.                                     break;
  2009.                                 case NSL_TYPE_LANGUAGE:
  2010.                                     if (*(structure + item->se_offset) < 13)
  2011.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2012.                                     else
  2013.                                         *(structure + item->se_offset) = 0;
  2014.                                     update_item_data(item);
  2015.                                     break;
  2016.                                 case NSL_TYPE_LINEFEEDS:
  2017.                                     if (*(structure + item->se_offset) < 2)
  2018.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2019.                                     else
  2020.                                         *(structure + item->se_offset) = 0;
  2021.                                     update_item_data(item);
  2022.                                     break;
  2023.                                 case NSL_TYPE_MOREMODE:
  2024.                                     if (*(structure + item->se_offset) < 2)
  2025.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2026.                                     else
  2027.                                         *(structure + item->se_offset) = 0;
  2028.                                     update_item_data(item);
  2029.                                     break;
  2030.                                 case NSL_TYPE_PHONENUMBER:
  2031.                                     break;
  2032.                                 case NSL_TYPE_PHONEVERIFICATION:
  2033.                                     if (*(structure + item->se_offset) < 3)
  2034.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2035.                                     else
  2036.                                         *(structure + item->se_offset) = 0;
  2037.                                     update_item_data(item);
  2038.                                     break;
  2039.                                 case NSL_TYPE_PROTOCOL:
  2040.                                     if (*(structure + item->se_offset) < 3)
  2041.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2042.                                     else
  2043.                                         *(structure + item->se_offset) = 0;
  2044.                                     update_item_data(item);
  2045.                                     break;
  2046.                                 case NSL_TYPE_STRING:
  2047.                                     {
  2048.                                         char buffer[80];
  2049.                                         editfield(buffer,structure + item->se_offset, item->se_length, item->fieldlen, 0, 0);
  2050.                                         strncpy(structure + item->se_offset,buffer,item->se_length - 1);
  2051.                                         update_item_data(item);
  2052.                                     }
  2053.                                     break;
  2054.                                 case NSL_TYPE_TIMEFORMAT:
  2055.                                     if (*(structure + item->se_offset) < 3)
  2056.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2057.                                     else
  2058.                                         *(structure + item->se_offset) = 0;
  2059.                                     update_item_data(item);
  2060.                                     break;
  2061.                                 case NSL_TYPE_DATEFORMAT:
  2062.                                     if (*(structure + item->se_offset) < 2)
  2063.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2064.                                     else
  2065.                                         *(structure + item->se_offset) = 0;
  2066.                                     update_item_data(item);
  2067.                                     break;
  2068.                                 case NSL_TYPE_TIMEZONE:
  2069.                                     if (*(structure + item->se_offset) < 24)
  2070.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2071.                                     else
  2072.                                         *(structure + item->se_offset) = 0;
  2073.                                     update_item_data(item);
  2074.                                     break;
  2075.                                 case NSL_TYPE_UBYTE:
  2076.                                     {
  2077.                                         char buffer[10];
  2078.                                         char src[10];
  2079.                                         LONG dest;
  2080.                                         if (*(structure + item->se_offset))
  2081.                                             sprintf(src,"%u",*(structure + item->se_offset));
  2082.                                         editfield(buffer,src, 3, item->fieldlen, 0, 0);
  2083.                                         StrToLong(buffer,&dest);
  2084.                                         *(structure + item->se_offset) = (UBYTE)dest;
  2085.                                     }
  2086.                                     break;
  2087.                                 case NSL_TYPE_ULONG:
  2088.                                     {
  2089.                                         char buffer[15];
  2090.                                         char src[15];
  2091.                                         LONG dest;
  2092.                                         if (*(structure + item->se_offset))
  2093.                                             sprintf(src,"%u",*(structure + item->se_offset));
  2094.                                         editfield(buffer,src, 10, item->fieldlen, 0, 0);
  2095.                                         StrToLong(buffer,&dest);
  2096.                                         *(structure + item->se_offset) = (UBYTE)dest;
  2097.                                     }
  2098.                                     break;
  2099.                                 case NSL_TYPE_USERID:
  2100.                                 case NSL_TYPE_USERIP:
  2101.                                     {
  2102.                                         char buffer[15];
  2103.                                         char src[15];
  2104.                                         LONG dest;
  2105.                                         if (*(structure + item->se_offset))
  2106.                                             sprintf(src,"%u",*(structure + item->se_offset));
  2107.                                         editfield(buffer,src, 10, item->fieldlen, 0, 0);
  2108.                                         StrToLong(buffer,&dest);
  2109.                                         *(structure + item->se_offset) = (ULONG)dest;
  2110.                                     }
  2111.                                     break;
  2112.                                 case NSL_TYPE_UWORD:
  2113.                                     {
  2114.                                         char buffer[15];
  2115.                                         char src[15];
  2116.                                         LONG dest;
  2117.                                         if (*(structure + item->se_offset))
  2118.                                             sprintf(src,"%u",*(structure + item->se_offset));
  2119.                                         editfield(buffer,src, 5, item->fieldlen, 0, 0);
  2120.                                         StrToLong(buffer,&dest);
  2121.                                         *(structure + item->se_offset) = (UWORD)dest;
  2122.                                     }
  2123.                                     break;
  2124.                                 case NSL_TYPE_GROUPBOOL:
  2125.                                     if (*(structure + item->se_offset) < 2)
  2126.                                         *(structure + item->se_offset) = *(structure + item->se_offset) + 1;
  2127.                                     else
  2128.                                         *(structure + item->se_offset) = 0;
  2129.                                     update_item_data(item);
  2130.                                     break;
  2131.                                 case NSL_TYPE_STRUCT:
  2132.                                     break;
  2133.                             }
  2134.                             break;
  2135.                         case NSL_TYPE_LINK:
  2136.                             switch (item->se_type)
  2137.                             {
  2138.                                 case NSL_TYPE_NOTDEFINED:
  2139.                                     if (item->var->nsltype == NSL_TYPE_LINK)
  2140.                                     {
  2141.                                     }
  2142.                                     else
  2143.                                     {
  2144.                                         if (item->var->nsltype == NSL_TYPE_MENU)
  2145.                                         {
  2146.                                             nslmenu->last_item = item;
  2147.                                             nslmenu = (NSLMenu *)item->var->data;
  2148.                                             item = nslmenu->last_item;
  2149.                                             rebuild = TRUE;
  2150.                                         }
  2151.                                     }            
  2152.                                     break;
  2153.                             }
  2154.                             break;
  2155.                         case NSL_TYPE_RETURN:
  2156.                             if (item->se_type == TRUE)
  2157.                                 nslmenu->var->result = TRUE;
  2158.                             else
  2159.                                 nslmenu->var->result = FALSE;
  2160.                             quit = TRUE;
  2161.                             break;
  2162.                     }
  2163.                     break;
  2164.                 case -101:
  2165.                     Conread(buffer,1,0);
  2166.                     switch(*buffer)
  2167.                     {
  2168.                         case 'D':                                                        // CURSER LEFT
  2169.                             JumpXY(item->X,item->Y);
  2170.                             ioprintf("%s",item->title);
  2171.                             if (item->ln_Pred && item->ln_Pred->ln_Pred)
  2172.                             {
  2173.                                 item = item->ln_Pred;
  2174.                                 JumpXY(item->X,item->Y);
  2175.                                 ioprintf("%s",item->title);
  2176.                             }
  2177.                             else
  2178.                             {
  2179.                                 if (nslmenu->itemlist.mlh_TailPred)
  2180.                                 {
  2181.                                     item = (NSLMenuItem *)nslmenu->itemlist.mlh_TailPred;
  2182.                                     JumpXY(item->X,item->Y);
  2183.                                     ioprintf("%s",item->title);
  2184.                                 }
  2185.                             }
  2186.                             break;
  2187.                         case 'C':                                                        // CURSER RIGHT
  2188.                             JumpXY(item->X,item->Y);
  2189.                             ioprintf("%s",item->title);
  2190.                             if (item->ln_Succ && item->ln_Succ->ln_Succ)
  2191.                             {
  2192.                                 item = item->ln_Succ;
  2193.                                 JumpXY(item->X,item->Y);
  2194.                                 ioprintf("%s",item->title);
  2195.                             }
  2196.                             else
  2197.                             {
  2198.                                 if (nslmenu->itemlist.mlh_Head)
  2199.                                 {
  2200.                                     item = (NSLMenuItem *)nslmenu->itemlist.mlh_Head;
  2201.                                     JumpXY(item->X,item->Y);
  2202.                                     ioprintf("%s",item->title);
  2203.                                 }
  2204.                             }
  2205.                             break;
  2206.                         case 'A':                                                        // CURSER UP
  2207.                             if (item->ln_Pred)
  2208.                             {
  2209.                                 struct NSLMenuItem *new_item = item->ln_Pred;
  2210.                                 while (new_item->ln_Pred && new_item->X != item->X)
  2211.                                     new_item = new_item->ln_Pred;
  2212.                                 if (!new_item->ln_Pred | new_item->X != item->X)
  2213.                                 {
  2214.                                     new_item = (NSLMenuItem *)nslmenu->itemlist.mlh_TailPred;
  2215.                                     while (new_item->ln_Pred && new_item->X != item->X)
  2216.                                         new_item = new_item->ln_Pred;
  2217.                                 }
  2218.                                 if (new_item)
  2219.                                 {
  2220.                                     if (new_item->ln_Pred && new_item->ln_Succ)
  2221.                                     {
  2222.                                         JumpXY(item->X,item->Y);
  2223.                                         ioprintf("%s",item->title);
  2224.                                         item = new_item;
  2225.                                         JumpXY(item->X,item->Y);
  2226.                                         ioprintf("%s",item->title);
  2227.                                     }
  2228.                                 }
  2229.                             }
  2230.                             break;
  2231.                         case 'B':                                                         // CURSER DOWN
  2232.                             if (item->ln_Succ)
  2233.                             {
  2234.                                 struct NSLMenuItem *new_item = item->ln_Succ;
  2235.                                 while (new_item->ln_Succ && new_item->X != item->X)
  2236.                                     new_item = new_item->ln_Succ;
  2237.                                 if (!new_item->ln_Succ | new_item->X != item->X)
  2238.                                 {
  2239.                                     new_item = (NSLMenuItem *)nslmenu->itemlist.mlh_Head;
  2240.                                     while (new_item->ln_Succ && new_item->X != item->X)
  2241.                                         new_item = new_item->ln_Succ;
  2242.                                 }
  2243.                                 if (new_item)
  2244.                                 {
  2245.                                     if (new_item->ln_Pred && new_item->ln_Succ)
  2246.                                     {
  2247.                                         JumpXY(item->X,item->Y);
  2248.                                         ioprintf("%s",item->title);
  2249.                                         item = new_item;
  2250.                                         JumpXY(item->X,item->Y);
  2251.                                         ioprintf("%s",item->title);
  2252.                                     }
  2253.                                 }
  2254.                             }
  2255.                             break;
  2256.                      }
  2257.                     break;
  2258.             }
  2259.         }
  2260. }
  2261.  
  2262. void update_item_data(NSLMenuItem *item)
  2263. {
  2264.     struct PortData *cport = (PortData *)FindTask(NULL)->tc_UserData;
  2265.     char buf[80];
  2266. //    if (item->se_offset)
  2267.     {
  2268.         int stringlen;
  2269.         char *structure = (char *)item->var->data;
  2270.         JumpXY(item->X + item->titlelen,item->Y);
  2271.         Writeio("", -1);
  2272.         *buf = 0;
  2273.         switch (item->se_type)
  2274.         {
  2275.             case NSL_TYPE_ACCESSGROUP:
  2276.                 sprintf(buf,"%u",*((ULONG *)(structure+item->se_offset)));
  2277.                 break;
  2278.             case NSL_TYPE_ANSICOLORS:
  2279.                 sprintf(buf,"%s",getstr(29,*((UWORD *)(structure+item->se_offset))));
  2280.                 break;
  2281.             case NSL_TYPE_ANSIMODE:
  2282.                 sprintf(buf,"%s",getstr(28,*((UWORD *)(structure+item->se_offset))));
  2283.             case NSL_TYPE_ANSITABS:
  2284.                 if (*(structure+item->se_offset))
  2285.                     sprintf(buf,"yes");
  2286.                 else
  2287.                     sprintf(buf,"no");
  2288.                 break;
  2289.             case NSL_TYPE_ARCMETHOD:
  2290.                 sprintf(buf,"%u",*(structure+item->se_offset));
  2291.                 break;
  2292.             case NSL_TYPE_BOOL:
  2293.                 sprintf(buf,"%s",getstr(0,*((UWORD *)(structure+item->se_offset))));
  2294.                 break;
  2295.             case NSL_TYPE_GROUPBOOL:
  2296.                 sprintf(buf,"%s",getstr(28,*((UWORD *)(structure+item->se_offset))));
  2297.                 break;
  2298.             case NSL_TYPE_CHARSET:
  2299.                 sprintf(buf,"%s",getstr(22,*((UWORD *)(structure+item->se_offset))));
  2300.                 break;
  2301.             case NSL_TYPE_COMPUTERTYPE:
  2302.                 sprintf(buf,"%s",getstr(31,*((UWORD *)(structure+item->se_offset))));
  2303.                 break;
  2304.             case NSL_TYPE_COUNTRY:
  2305.                 sprintf(buf,"%s",getstr(21,*((UWORD *)(structure+item->se_offset))));
  2306.                 break;
  2307.             case NSL_TYPE_DATE:
  2308.                 DateToString(buf, (struct Date *)(structure+item->se_offset),0);
  2309.                 break;
  2310.             case NSL_TYPE_DIRECTORYPATH:
  2311.                 sprintf(buf,"%s",structure+item->se_offset);
  2312.                 break;
  2313.             case NSL_TYPE_EOLSEQUENCE:
  2314.                 sprintf(buf,"%u",*(structure+item->se_offset));
  2315.                 break;
  2316.             case NSL_TYPE_FILENAME:
  2317.                 sprintf(buf,"%s",structure+item->se_offset);
  2318.                 break;                
  2319.             case NSL_TYPE_GENDER:
  2320.                 sprintf(buf,"%s",getstr(20,*((UWORD *)(structure+item->se_offset))));
  2321.                 break;
  2322.             case NSL_TYPE_HELPLEVEL:
  2323.                 sprintf(buf,"%s",getstr(32,*((UWORD *)(structure+item->se_offset))));
  2324.                 break;
  2325.             case NSL_TYPE_ITEMTYPE:
  2326.                 sprintf(buf,"%s",getstr(96,*((UWORD *)(structure+item->se_offset))));
  2327.                 break;
  2328.             case NSL_TYPE_LANGUAGE:
  2329.                 sprintf(buf,"%s",getstr(21,*((UWORD *)(structure+item->se_offset))));
  2330.                 break;
  2331.             case NSL_TYPE_LINEFEEDS:
  2332.                 sprintf(buf,"%s",getstr(26,*((UWORD *)(structure+item->se_offset))));
  2333.                 break;
  2334.             case NSL_TYPE_MOREMODE:
  2335.                 sprintf(buf,"%s",getstr(34,*((UWORD *)(structure+item->se_offset))));
  2336.                 break;
  2337.             case NSL_TYPE_PHONENUMBER:
  2338.                 sprintf(buf,"%s",structure+item->se_offset);
  2339.                 break;
  2340.             case NSL_TYPE_PHONEVERIFICATION:
  2341.                 sprintf(buf,"%s",getstr(15,*((UWORD *)(structure+item->se_offset))));
  2342.                 break;
  2343.             case NSL_TYPE_PROTECTION:
  2344.                 {
  2345.                     ULONG protection = (ULONG)*(structure+item->se_offset);
  2346.                 strcpy(buf,"--------");
  2347.                 if (protection & FIBF_SCRIPT)
  2348.                     buf[1]='s';
  2349.                 if (protection & FIBF_PURE)
  2350.                     buf[2]='p';
  2351.                 if (protection & FIBF_ARCHIVE)
  2352.                     buf[3]='a';
  2353. //                if (protection & FIBF_READ)
  2354.                     buf[4]='r';
  2355. //                if (protection & FIBF_WRITE)
  2356.                     buf[5]='w';
  2357. //                if (protection & FIBF_EXECUTE)
  2358.                     buf[6]='e';
  2359. //                if (protection & FIBF_DELETE)
  2360.                     buf[7]='d';
  2361.                 }
  2362.                 break;
  2363.             case NSL_TYPE_PROTOCOL:
  2364.                 sprintf(buf,"%s",getstr(33,*((UWORD *)(structure+item->se_offset))));
  2365.                 break;
  2366.             case NSL_TYPE_STRING:
  2367.                 sprintf(buf,"%s",structure+item->se_offset);
  2368.                 break;
  2369.             case NSL_TYPE_TIMEFORMAT:
  2370.                 sprintf(buf,"%s",getstr(24,*((UWORD *)(structure+item->se_offset))));
  2371.                 break;
  2372.             case NSL_TYPE_TIMEZONE:
  2373.                 sprintf(buf,"%s",getstr(16,*((UWORD *)(structure+item->se_offset))));
  2374.                 break;
  2375.             case NSL_TYPE_DATEFORMAT:
  2376.                 sprintf(buf,"%s",getstr(25,*((UWORD *)(structure+item->se_offset))));
  2377.                 break;
  2378.             case NSL_TYPE_UBYTE:
  2379.                 sprintf(buf,"%u",*(structure+item->se_offset));
  2380.                 break;
  2381.             case NSL_TYPE_ULONG:
  2382.                 sprintf(buf,"%u",*((ULONG *)(structure+item->se_offset)));
  2383.                 break;
  2384.             case NSL_TYPE_USERID:
  2385.                 sprintf(buf,"%u",*((ULONG *)(structure+item->se_offset)));
  2386.                 break;
  2387.             case NSL_TYPE_USERIP:
  2388.                 sprintf(buf,"%u",*((ULONG *)(structure+item->se_offset)));
  2389.                 break;
  2390.             case NSL_TYPE_UWORD:
  2391.                 sprintf(buf,"%u",*((UWORD *)(structure+item->se_offset)));
  2392.                 break;
  2393.         }
  2394.         if ((stringlen = strlen(buf)))
  2395.         {
  2396.             if (stringlen < item->fieldlen)
  2397.             {
  2398.                 char *bufptr = buf;
  2399.                 int counter = 0;
  2400.                 while (*bufptr)
  2401.                     bufptr++;
  2402.                 for (counter = stringlen; counter < item->fieldlen; counter++)
  2403.                     *bufptr++ = ' ';
  2404.                 *bufptr = 0;
  2405.                 Writeio(buf,-1);
  2406.             }
  2407.             else
  2408.             {
  2409.                 if (stringlen > item->fieldlen)
  2410.                 {
  2411.                     Writeio(buf,item->fieldlen);
  2412.                 }
  2413.                 else
  2414.                     Writeio(buf,-1);
  2415.             }
  2416.         }
  2417.     }
  2418. }
  2419.  
  2420. void build_menu(NSLMenu *nslmenu)
  2421. {
  2422.     struct PortData *cport=(PortData *)FindTask(NULL)->tc_UserData;
  2423.     struct NSLMenuItem *item;
  2424.     char counter;
  2425.     CLS();
  2426.     item = (NSLMenuItem *)nslmenu->itemlist.mlh_Head;
  2427.     while (item->ln_Succ)
  2428.     {
  2429.         JumpXY(item->X,item->Y);
  2430.         ioprintf("%s",item->title);
  2431.         update_item_data(item);
  2432.         item = item->ln_Succ;
  2433.     }
  2434. }
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.